jQuery - 与向上滑动(折叠)下拉菜单有关的问题 [英] jQuery - Issue relating to sliding up (collapsing) drop down menus

查看:65
本文介绍了jQuery - 与向上滑动(折叠)下拉菜单有关的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了jQuery的问题,我需要一些建议。我无法弄清楚我做错了什么。



这是一个场景:



我有一个使用jQuery Bootstrap代码创建的下拉框。它使用slideToggle向下滑动菜单。单击下拉列表时工作正常。当我在菜单中点击一个元素时,我遇到的问题是尝试让它重新滑动。



这是我到目前为止滑动的内容菜单备份。



I am having an issue with jQuery that I need some advice on. I can't figure out what I'm doing wrong.

Here is the scenario:

I have a dropdownbox that was created with jQuery Bootstrap code. It uses the slideToggle to slide the menu down. That is working fine when the dropdown is clicked. The issue I'm having is trying to get it to slide back up when an element is clicked within the menu.

Here is what I have so far to slide the menu back up.

$(document).on('click', '.dropdown-menu li a', function ()
{
    $(this).next('.dropdown-menu').slideUp(500);
}





目前选择菜单元素时什么都不做。



我错过了一些明显的东西吗?



谢谢大家!



It currently does nothing when a menu element is selected.

Am I missing something obvious?

Thanks everyone!

推荐答案

document )。on(' 单击 。 -menu li a' function ()
{
(document).on('click', '.dropdown-menu li a', function () {


this )。next(' .downdown-menu')。slideUp ( 500 );
}
(this).next('.dropdown-menu').slideUp(500); }





选择菜单元素时,它当前无效。



我错过了一些明显的东西吗?



谢谢大家!



It currently does nothing when a menu element is selected.

Am I missing something obvious?

Thanks everyone!


我自己想出来了。它与元素的ID和我正在检查的事件有关。
I figured it out myself. It had to do with the ID of the element and the event I was checking for.


这篇关于jQuery - 与向上滑动(折叠)下拉菜单有关的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆