Text blinking jQuery

后端 未结 30 1899
我寻月下人不归
我寻月下人不归 2020-11-27 03:23

What is an easy way to make text blinking in jQuery and a way to stop it? Must work for IE, FF and Chrome. Thanks

30条回答
  •  旧巷少年郎
    2020-11-27 03:59

    Indeed a plugin for a simple blink effect is overkill. So after experimenting with various solutions, I have choosen between one line of javascript and a CSS class that controls exactly how I want to blink the elements (in my case for the blink to work I only need to change the background to transparent, so that the text is still visible):

    JS:

    $(document).ready(function () {
            setInterval(function () { $(".blink").toggleClass("no-bg"); }, 1000);
        });
    

    CSS:

    span.no-bg {
        background-color: transparent;
    }
    

    Full example at this js fiddle.

提交回复
热议问题