开发者

What is wrong with this clear timeout?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜