jQuery 滑动开关不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15479711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery slidetoggle not working?
提问by temporary_user_name
I'm just trying to make a small box slide down from the pictureControls div which acts as a button, but slideToggle is doing nothing-- it just sort of glitches into place and back again. Read a tonof other similar questions, none helped or applied.
我只是想让一个小框从作为按钮的图片控件 div 向下滑动,但是 slideToggle 什么也没做——它只是有点小故障到位然后又回来了。阅读大量其他类似问题,但没有任何帮助或应用。
$('#pictureControls').click(function(event) {
$('#pictureControlsMenu').slideToggle(300);
event.stopPropagation();
});
回答by Reinstate Monica Cellio
slideToggle
wasn't working because the table is not a block element. In the following update I've made it a block element (instead of display:none), and then hidden it on page load with jQuery...
slideToggle
没有工作,因为表不是块元素。在以下更新中,我将其设为块元素(而不是 display:none),然后在页面加载时使用 jQuery 将其隐藏...
回答by isherwood
Try sliding a div rather than the table:
尝试滑动 div 而不是表格:
<div id="pictureControls" onclick="" title="Picture Controls" alt="Picture Controls">
<div id="pictureControlsWrapper">
<table id="pictureControlsMenu">
Since I wasn't sure what the HTML click function and the other thing were doing, I removed them along with the stopPropogation statement.
由于我不确定 HTML click 函数和其他东西在做什么,我将它们与 stopPropogation 语句一起删除。