我在執(zhí)行animate動畫完畢后調(diào)用回調(diào)函數(shù),要直接寫函數(shù)名“aniDiv”就能調(diào)用這個函數(shù),而不是寫成“aniDiv()”來調(diào)用為什么?如果我不寫在回調(diào)函數(shù)中而是另起一行去調(diào)用函數(shù)就必須寫括號,為什么了???<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); ? ? ?//該處調(diào)用aniDiv函數(shù),沒寫小括號,為什么?? }? 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中回調(diào)函數(shù)沒加小括號,為什么???
快樂崇拜tager
2016-06-29 16:04:39