How to Make Text Blink with jQuery?

DDD
Release: 2024-11-01 15:51:31
Original
1011 people have browsed it

How to Make Text Blink with jQuery?

Making Text Blink with jQuery

To make text blink in jQuery, a JavaScript library for manipulating HTML elements, use the following steps:

<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

This code uses the setInterval() method to repeatedly toggle the visibility of the element with the class "blink" every 500 milliseconds. When the visibility is "hidden," the text will disappear, and when it's "visible," the text will be displayed.

To stop the blinking effect, clear the interval using clearInterval() and the interval ID that was returned when setInterval() was called.

The above is the detailed content of How to Make Text Blink with 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!