문제

jQuery newb here. I want to make a button blink(but not hide). I have this code that I would think work but doesn't:

$("#refresh-60-sec").addClass("pressed-button")
                        .delay(1000)
                        .removeClass("pressed-button")
                        .delay(1000)
                        .addClass("pressed-button")
                        .delay(100)
                        .removeClass("pressed-button")
                        .delay(100)
                        .addClass("pressed-button");

This code just seems to leave the button in the state of the last addClass. Why? and/or how can I achieve the same effect? (That is the brief blinking of an element)

Thanks.

도움이 되었습니까?

해결책

I agree with Kevin I would create blinking function with fades (in and out) on an interval, like this:

function blink() {
    elem.fadeOut(500, function () {
        elem.fadeIn(500);
    });
}
setInterval(blink, 500);

see fiddle for working example, http://jsfiddle.net/tiri/2mkPF/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top