开发者

What is wrong with this clear timeout?

开发者 https://www.devze.com 2023-03-31 01:09 出处:网络
It\'s not working for some reason (in coffeescript) afunction = () -> window.clearTimeout(timeoutID)

It's not working for some reason (in coffeescript)

afunction = () ->

    window.clearTimeout(timeoutID)
    $(".x").text("#{message}").addClass("y")
    timeoutID = window.setTimeout (-> 
        $(".x").removeClass("y")
    ), 4000
开发者_如何学C


timeoutID is a local variable, so each time you call the method, timeoutID starts off undefined.

0

精彩评论

暂无评论...
验证码 换一张
取 消