Showing content based on a nav link clicked

后端 未结 4 1354
长情又很酷
长情又很酷 2021-01-16 13:09

I have a menu selection that looks like this:

  • About
4条回答
  •  星月不相逢
    2021-01-16 13:29

    $(".menu").children().click(function(){
        $(".menu").children(function(){
            $("."+$(this).attr("class").replace("Nav","")).hide();
        })
        $("."+$(this).attr("class").replace("Nav","")).show();
    })
    

    This would be a universal solution, considering that you can have any menu item with class "someItemNav"; if it's clicked any items are hidden and only "someItem" is shown.

提交回复
热议问题