Text blinking jQuery

后端 未结 30 2019
我寻月下人不归
我寻月下人不归 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:44

    This is what ended up working best for me. I used jQuery fadeTo because this is on WordPress, which already links jQuery in. Otherwise, I probably would have opted for something with pure JavaScript before adding another http request for a plugin.

    $(document).ready(function() {
        // One "blink" takes 1.5s
        setInterval(function(){
            // Immediately fade to opacity: 0 in 0ms
            $(".cursor").fadeTo( 0, 0);
            // Wait .75sec then fade to opacity: 1 in 0ms
            setTimeout(function(){
                $(".cursor").fadeTo( 0, 1);
            }, 750);
        }, 1500);
    });
    

提交回复
热议问题