Jquery: Hide all children, then show a specific element
问题 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(function() { $(this).hide(); }); $(name).show(); } then i call the function from an onmouse event like: subDisplay(#DivIwantToShow); But nothing displays... What am i doing wrong? 回答1: 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