Home > Web Front-end > CSS Tutorial > How to Make Text Blink Using jQuery?

How to Make Text Blink Using jQuery?

DDD
Release: 2024-10-30 03:26:02
Original
258 people have browsed it

How to Make Text Blink Using jQuery?

Text Blinking with jQuery

Blinking text can be easily achieved using jQuery. Here's a code snippet that makes any text element with the class "blink" blink indefinitely:

<code class="javascript">$('.blink').each(function() {
    var elem = $(this);
    setInterval(function() {
        if (elem.css('visibility') == 'hidden') {
            elem.css('visibility', 'visible');
        } else {
            elem.css('visibility', 'hidden');
        }    
    }, 500);
});</code>
Copy after login

To stop the blinking, simply clear the interval associated with the text element:

<code class="javascript">$('.blink').each(function() {
    var elem = $(this);
    clearInterval(elem.data('blinkInterval'));
});</code>
Copy after login

The above is the detailed content of How to Make Text Blink Using jQuery?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template