Jquery:新的 FadeToggle,我可以在切换的第二个操作上运行代码吗?
所以当我点击#mybutton
时,它会淡入.mybox
。是否可以采用下面的代码,并添加类似 .animate({'width':'toggle'})
的内容或在第一次切换,然后第二次激活切换时不激活延迟? 我该怎么做?最简单/最简单的方法?
这是我要使用的代码:
$('#mybutton').click(function(){
$('.mybox').fadeToggle(500)
})
so when i click #mybutton
it will fade in .mybox
. is it possible to take my code below, and add something like .animate({'width':'toggle'})
or add a .delay(2000)
before the first time it's toggled, then not activate the delay when the toggle is activated the second time?
how would i do that? easiest/simplest way?
here's my code to work with:
$('#mybutton').click(function(){
$('.mybox').fadeToggle(500)
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
one()
绑定一次性事件处理程序,然后绑定“真正的”永久事件处理程序将在这里工作:请在此处查看这个简单的演示: http://jsfiddle.net/一江/2m3bb/
Using
one()
to bind a one-time event handler, then binding the "real" permanent event handler will would work here:See this simple demo here: http://jsfiddle.net/yijiang/2m3bb/
这是我的做法,使用
setTimeout()
:Here's how I'd do it, using
setTimeout()
:您可以仅使用
toggle()
而不是fadeToggle()
来获得更多控制。You can use just
toggle()
instead offadeToggle()
to get a bit more control.