我正在尝试使用列表元素为我的网站构建一个简单的菜单。问题是我想在单击箭头时显示'.second-row' div并隐藏任何其他打开的,但我尝试的所有方式都不起作用。
有人可以帮助我吗?例子在这里
我正在尝试使用列表元素为我的网站构建一个简单的菜单。问题是我想在单击箭头时显示'.second-row' div并隐藏任何其他打开的,但我尝试的所有方式都不起作用。
有人可以帮助我吗?例子在这里
You need to get the second-row
which corresponds to the arrow-1
that was clicked:
$('a.arrow-1 ').click(function () {
$('.second-row').slideUp();
$(this).parent('.first-row').siblings('.second-row').slideDown();
});
Note: You'll probably want to add some logic to check the last clicked arrow-1
, and return if it's the same as the current clicked one so that the slideUp()/slideDown()
doesn't occur when clicking the same arrow-1
twice.
我只是改变了点击事件
$('a.arrow-1 ').click(function () {
//alert("clicked");
var cli=$(this).closest('li').find('.second-row');
alert(cli);
$(cli).slideToggle();
});
你可以从这里得到工作副本
快乐编码:)