我在執行animate動畫完畢后調用回調函數,要直接寫函數名“aniDiv”就能調用這個函數,而不是寫成“aniDiv()”來調用為什么?如果我不寫在回調函數中而是另起一行去調用函數就必須寫括號,為什么了???<html><head><script type="text/javascript" src="/jquery/jquery.js"></script><script type="text/javascript">?$(document).ready(function(){? function aniDiv(){? ? $("#box").animate({width:300},"slow");? ? $("#box").animate({width:100},"slow",aniDiv); ? ? ?//該處調用aniDiv函數,沒寫小括號,為什么?? }? aniDiv();? $(".btn1").click(function(){? ? $(":animated").css("background-color","blue");? });});</script><style>?div{background:#98bf21;height:40px;width:100px;position:relative;margin-bottom:5px;}</style></head><body><div></div><div id="box"></div><div></div><button class="btn1">Mark animated element</button></body></html>
在JQuery中回調函數沒加小括號,為什么???
快樂崇拜tager
2016-06-29 16:04:39