SlideDown然后调用自定义函数
很难理解为什么我的函数被调用两次。
我试图检测何时调用单选按钮(intRev_yes),检查div是否为空,向下滑动另一个div,然后调用动态创建日期字段的custome函数。
if(this.id=="intRev_yes"){
if($('div#mainField').is(':empty')){
$('.intRevSections').slideDown('slow',function(){
current=-1;
addIrField();
});
}
}
当我在每个阶段发出警报时,在到达末尾(即 addIrField())后,脚本似乎返回到 SlideDown() 部分并调用 addIrField()。我不明白为什么,没有循环。 current
用作日期字段的索引。
Having difficulty understanding why my function is being called twice.
I'm trying to detect when a radio button is called (intRev_yes), check if a div is empty, slide down another div and then call a custome function which dynamically creates a date field.
if(this.id=="intRev_yes"){
if($('div#mainField').is(':empty')){
$('.intRevSections').slideDown('slow',function(){
current=-1;
addIrField();
});
}
}
When I alert out at each stage, after getting to the end (i.e. addIrField()), the script seems to go back to the slideDown() section and recalls addIrField(). I can't understand why, there are no loops. current
is used as an index for the date field.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可能是从冒泡的 Dom 事件中调用此函数的。请参阅 http://en.wikipedia.org/wiki/DOM_events 检查情况是否如此。
You are probably calling this from a Dom event that bubbles. See http://en.wikipedia.org/wiki/DOM_events to check if that's the case.
另一种情况是:
如果您有两个类名为
.intRevSections
的元素,slideDown 将运行两次,回调将触发两次...希望这会有所帮助,Sinan。
Another case would be:
If you have two elements having class name
.intRevSections
slideDown would run twice, and callback would fire twice...Hope this helps, Sinan.
司南已经发现了这个问题,但实际上并没有发布答案。答案是:
找出为什么你有两个 div(如果你从 JS 创建它们,另一个函数也可能运行两次)
你可能还想修复代码,以便它只使用一个 div,即使你有两个 div
Sinan already discovered the problem, but did not in fact post an answer. the answer is:
Find out why You have two divs (if You create them from JS the other function might be run twice as well)
You may also want to fix the code so that it uses only one div even if You have two of them
试试这个:
try this:
Jquery animate 完整为我工作
Jquery animate complete worked for me