Home > Article > Web Front-end > 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>
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!