开发者

Showing only a `<div>` element, and all its children

开发者 https://www.devze.com 2023-03-24 22:22 出处:网络
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\'>,

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消