jQuery .show('slide', { direction: 'right' }) 不起作用,但 .show('slide') 可以

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14816525/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 13:57:40  来源:igfitidea点击:

jQuery .show('slide', { direction: 'right' }) doesn't work, but .show('slide') does

jqueryshowslide

提问by ESDictor

I'm inserting a menu choice at the beginning of a top menu (ListItems) and using

我在顶部菜单 (ListItems) 的开头插入一个菜单选项并使用

$('#newMenuItem').show('slide');

successfully. However, I didn't like the way it slid in from the upper-left, so I changed it to

成功地。然而,我不喜欢它从左上角滑入的方式,所以我把它改成了

$('#newMenuItem').show('slide', { direction: 'right' });

Unfortunately, once I changed it I no longer get the new item at all. In fact, no code lower than the above line is getting executed anymore.

不幸的是,一旦我更改了它,我就再也无法获得新项目了。事实上,低于上一行的代码不再被执行。

Is there an obvious reason why this wouldn't work? I'm using jquery-1.7.1 shipped with Visual Studio 2012.

是否有明显的原因为什么这不起作用?我正在使用 Visual Studio 2012 附带的 jquery-1.7.1。

回答by Mahn

The effect of sliding in a specific direction doesn't come bundled with vanilla jQuery, but it's instead part of jQuery UI; including jQuery UI (in addition to jQuery) in your project should make it available. See also the documentation for the effect here.

向特定方向滑动的效果并不与普通 jQuery 捆绑在一起,而是jQuery UI的一部分;在您的项目中包含 jQuery UI(除了 jQuery)应该使其可用。另请参阅此处的效果文档。

回答by Nicolai Robles

You can try $('#newMenuItem').slideDown();

你可以试试$('#newMenuItem').slideDown()