Jquery - determining which link was clicked

后端 未结 5 2001
轮回少年
轮回少年 2020-12-20 07:18

I have several similar links that trigger different navigation divs to appear. I am trying to find a way in JQuery to determine which of the links was clicked and then trig

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 07:41

    How about something like this jsFiddle?

    When you click a link, the corresponding div is shown while all others are hidden.

    $('#hidden1,#hidden2,#hidden3').hide();
    $("#nav1,#nav2,#nav3").click(function(e)
    {
        e.preventDefault();
        $('#hidden1,#hidden2,#hidden3').hide();
        $('div:eq('+$(this).index()+')').show();
    });
    

提交回复
热议问题