Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Why does this empty the text immediately (ignoring delay)?

$('#error_box_text').html('error text').delay(5000).html('')

#

jQuery 1.4

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
493 views
Welcome To Ask or Share your Answers For Others

1 Answer

delay will never delay regular methods - only those who are pushed to the animation/effect chain. If you want to delay your html() call, use queue ( http://api.jquery.com/queue/ ):

$('#error_box_text').html('error text').delay(5000).queue(function() {
   $(this).html('')
});

It would be nice if you could do

$('#error_box_text').html('error text').delay(5000, function() { $(this).html('') });

but this isn't possible (yet).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...