Javascript 单击下拉菜单隐藏其他下拉菜单
我有一个下拉数据过滤器,使用同位素插件 我试图关闭一个下拉列表,它在单击另一个列表项时打开,当下拉列表打开时,箭头向下旋转 我想知道我如何才能做到这一点 这是我的Javascript 单击下拉菜单隐藏其他下拉菜单,javascript,jquery,html,drop-down-menu,Javascript,Jquery,Html,Drop Down Menu,我有一个下拉数据过滤器,使用同位素插件 我试图关闭一个下拉列表,它在单击另一个列表项时打开,当下拉列表打开时,箭头向下旋转 我想知道我如何才能做到这一点 这是我的 我使用了一个教程中的jquery,因此它在html中,如果我将它移动到它自己的.js文件中,它将不起作用。我不确定您真正想要的是什么,但下面是我实现目标的尝试 function toggle_visibility(e) { if (e.target.parentNode != this) return; e.preve
我使用了一个教程中的jquery,因此它在html中,如果我将它移动到它自己的.js文件中,它将不起作用。我不确定您真正想要的是什么,但下面是我实现目标的尝试
function toggle_visibility(e) {
if (e.target.parentNode != this) return;
e.preventDefault();
$(this).toggleClass('open').siblings('.hasarrow.open').removeClass('open');
}
jQuery(function ($) {
$('.productfilters').on('click', '.hasarrow', toggle_visibility);
});
什么是“nfbtv”?没有这样的id,因此
click()
处理程序无法如此完美地工作!但当我选择下拉列表时,它会关闭并再次打开,以避免它关闭下拉列表并再次打开。
function toggle_visibility(e) {
if (e.target.parentNode != this) return;
e.preventDefault();
$(this).toggleClass('open').siblings('.hasarrow.open').removeClass('open');
}
jQuery(function ($) {
$('.productfilters').on('click', '.hasarrow', toggle_visibility);
});
Hi Please have a look to this link. I make it to work for your requirement.
If you want to change the arrow then add a class which will have down arrow
css when you toggling it to down.