Show one div while hiding other divs with jquery when clicking on links

后端 未结 4 1716
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-19 21:18

I am trying to create a navigation scheme that has a series of links and number of divs. When I click on link 1 I want to show div 1. If I click on link 2 I want to hide 1 a

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-19 21:56

    $("#navigation a").on(...
    

    that's it really so to bind the click event only to your navigation links; your code is binding this event to all links that it will find in the document body so you just need a more precise selector

    nb: you should delegate

提交回复
热议问题