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

How to Make Text Blink Using jQuery?

DDD
DDDOriginal
2024-10-30 03:26:02301browse

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>

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>

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!

Statement:
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