I have a rather complex HTML page, with a large DOM ele开发者_C百科ment tree. For a specified <div id='mydiv'>
, I would like to hide all DOM elements not contained in <div id='mydiv'>
, and show all DOM elements contained in (and including) <div id='mydiv'>
.
The jQuery code I have tried is:
$('*').hide();
$('#mydiv').show();
but this doesn't do what I want.
$('body > *').hide();
$('#mydiv').show();
http://jsfiddle.net/efortis/VC5Q6/
精彩评论