Jquery: Hide all children, then show a specific element

后端 未结 7 1772
忘了有多久
忘了有多久 2021-01-03 17:59

I want to hide all child elements in a div. And then show a specific one passed on to the function.

function subDisplay(name) {
   $(\"#navSub\").each(functi         


        
7条回答
  •  情书的邮戳
    2021-01-03 18:15

    You need to hide the children and not the containing div.

    $("#navSub").children().hide();

    So now if the div you are trying to show is an element in the parent div it will still show while the others stay hidden.

提交回复
热议问题