How to hide a DIV element using RegEx and Jquery
I would like to hide all other element except class="imagebrowser"
in following,
<div class="entry">
<p>Heading 1</p>
<p>Heading 2</p>
...
<p>Heading n</p>
<b>This is abold text</b>
<div>This is a div element</div>开发者_高级运维
<div class="imagebrowser">
Hello world
</div>
</div>
Expected result,
<div class="entry">
<div class="imagebrowser">
Hello world
</div>
</div>
Any help please
Try this
$(".entry").children(":not(.imagebrowser)").hide();
$('div.entry div').not('.imagebrowser').hide();
This will hide all divs inside the "entry" div other than those with the class "imagebrowser".
Have you tried:
$('.entry').children().hide();
$('.imagebrowser').show();
This should hide all the contents of the entry div, including the p tags, and then show the imagebrowser div afterwards.
This code worked for me. You can replace $(this).val()
with #target
$('.'+ $(this).val()).show(); $('.tabcontent2 tr:not(.'+ $(this).val() +')').hide();
精彩评论