Text blinking jQuery

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

    I like alex's answer, so this is a bit of an extension of that without an interval (since you would need to clear that interval eventually and know when you want a button to stop blinking. This is a solution where you pass in the jquery element, the ms you want for the blinking offset and the number of times you want the element to blink:

    function blink ($element, ms, times) {
        for (var i = 0; i < times; i++) {
            window.setTimeout(function () {
                if ($element.is(':visible')) {
                    $element.hide();
                } else {
                    $element.show();
                }
            }, ms * (times + 1));
        }
    }
    

提交回复
热议问题