"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Make Text Blink Using jQuery?

How to Make Text Blink Using jQuery?

Published on 2024-11-12
Browse:776

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:

$('.blink').each(function() {
    var elem = $(this);
    setInterval(function() {
        if (elem.css('visibility') == 'hidden') {
            elem.css('visibility', 'visible');
        } else {
            elem.css('visibility', 'hidden');
        }    
    }, 500);
});

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

$('.blink').each(function() {
    var elem = $(this);
    clearInterval(elem.data('blinkInterval'));
});
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3