触发toggle()中的第二个函数
有没有办法可以调用 toggle(function(){},function(){})
中的第二个函数
Is there a way I can call the second function in toggle(function(){},function(){})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您确实想要的话,您可以跳过切换到下一个功能,例如:
然后您可以手动前进
.toggle()
函数数组(不调用第一个函数),如下所示:然后只需单击该元素或 < code>$("div").click() 等,它将触发第二个函数。
您可以在这里尝试一下,请注意,这仅适用于 jQuery 1.4+,而且实际上只是为了表明这是可能的。但是,您应该以相反的顺序绑定它们,或者按照其他答案的建议为第二个参数指定一个命名函数。
You could skip the toggle to the next function, if you really wanted to I suppose, for example:
Then you can manually advance the
.toggle()
function array (without calling the first function), like this:Then just click the element or
$("div").click()
, etc, and it'll fire the second function.You can give it a try here, note that this only works in jQuery 1.4+ and is really just to show it's possible. You should however either bind them in reverse order, or give the second argument a named function as the other answers suggest.
怎么样
how about
我建议这样的解决方案:
现在你可以按照你想要的方式称呼它:)
I suggest such solution:
And now you can call it how you want :)