0

我正在尝试使用列表元素为我的网站构建一个简单的菜单。问题是我想在单击箭头时显示'.second-row' div并隐藏任何其他打开的,但我尝试的所有方式都不起作用。

有人可以帮助我吗?例子在这里

4

2 回答 2

1

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();
});

Here's an updated fiddle

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.

于 2013-04-25T14:38:11.180 回答
0

我只是改变了点击事件

$('a.arrow-1 ').click(function () {
            //alert("clicked");
            var cli=$(this).closest('li').find('.second-row');
            alert(cli);
            $(cli).slideToggle();
        });

你可以从这里得到工作副本

快乐编码:)

于 2013-04-25T14:47:29.030 回答