陪伴而非守候
2018-12-07 09:37:25
我的代碼:
<!DOCTYPE html><html><head> <title>Demo</title> <script src="jquery.min.js" type="text/javascript"></script> <style type="text/css"> #test{ width:100px; height:100px; background:#CCC; } </style> <script type="text/javascript"> $(function(){ //$("#test").delay(2000).hide(); $("#test").show(500).delay(2000).hide(500); //$("#test").show().delay(2000).hide(); }); </script></head><body> <div id="test"></div></body></html>
為什么用我注釋掉的兩種寫(xiě)法不行?
4 回答

哆啦的時(shí)光機(jī)
TA貢獻(xiàn)1779條經(jīng)驗(yàn) 獲得超6個(gè)贊
jQuery文檔中已經(jīng)說(shuō)明了這個(gè):
Only subsequent events in a queue are delayed; for example this will?not?delay the no-arguments forms of?
.show()
?or?.hide()
?which do not use the effects queue.
在隊(duì)列中的事件才能被delay

米琪卡哇伊
TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊
我覺(jué)得“最佳答案”沒(méi)答到點(diǎn)上,動(dòng)畫(huà)效果本來(lái)默認(rèn)就是在“fx”隊(duì)列里的,“$("#test").show(500).delay(2000).hide(500);”事實(shí)上應(yīng)該是可行的,我先hide再show的結(jié)果是可行。
添加回答
舉報(bào)
0/150
提交
取消