滑动菜单时隐藏图像的问题
我有一个带有 SlideUp 和 SlideDown 的菜单。
用户单击菜单区域,菜单将打开,并且带有十字的图像变得可见。 要关闭按钮,用户单击图像,该图像就会变得不可见。
我在这一步遇到了问题。
看看这个小提琴: http://jsfiddle.net/pedroR/7YNJY/3/
注意:由于图像,请在 Chrome 或 IE 中看到此小提琴
谢谢
I've a menu with slideUp and SlideDown.
The user clicks in menuArea and the menu is opened and an image with a cross becomes visible.
To close the button the user click in the image, and that image becomes invisible.
I'm having a problem in this step.
Look at this fiddle: http://jsfiddle.net/pedroR/7YNJY/3/
NOTE: See this fiddle in Chrome or IE because of the image
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是
img
包含在#menuText
元素中。这意味着当您单击img
元素时,#menuText
的单击事件处理程序也会被触发,并且当它运行时,它会淡出img
您可以通过向img
点击事件处理程序添加参数并调用stopPropagation 来防止事件冒泡:
这是一个 工作示例。
The problem is that the
img
is contained within the#menuText
element. That means when you click theimg
element, the click event handler for#menuText
is also fired, and when that runs, it fades theimg
back in.You can prevent that by adding an argument to the
img
click event handler, and callingstopPropagation
to prevent the event from bubbling up:Here's a working example.
http://jsfiddle.net/7YNJY/12/ 在这里尝试一下。你可以把动画放回去,但我只是把它简化了一点,以便于阅读。
http://jsfiddle.net/7YNJY/12/ here try this out. You can put the animate back in, but i just dumbed it down a little bit to make it easier to read.
看看这是否是您正在寻找的结果: http://jsfiddle.net/rkw79/7YNJY/13 /
See if this is the result you are looking for: http://jsfiddle.net/rkw79/7YNJY/13/