开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜