How do I stop an effect in jQuery

后端 未结 4 1631
Happy的楠姐
Happy的楠姐 2020-12-17 16:39

I have a page that uses

$(id).show(\"highlight\", {}, 2000);

to highlight an element when I start a ajax request, that might fail so that

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-17 17:08

    .stop(true,true) will freeze the effect so if it's invisible at the time then it remains invisible. This could be a problem if you are using the pulsate effect.

    $('#identifier').effect("pulsate", {times:5}, 1000);
    

    To get around this I added

    $('#identifier').stop(true, true).effect("pulsate", { times: 1 }, 1);
    

提交回复
热议问题