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.
精彩评论