如何使用RegEx和Jquery隐藏DIV元素 [英] How to hide a DIV element using RegEx and Jquery

查看:44
本文介绍了如何使用RegEx和Jquery隐藏DIV元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在下面隐藏除class="imagebrowser"之外的所有其他元素,

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>

预期结果,

<div class="entry">

    <div class="imagebrowser">
        Hello world
    </div>
</div>

请帮助

推荐答案

$('div.entry div').not('.imagebrowser').hide();

这将隐藏除"imagebrowser"类之外的所有"div"中的div.

This will hide all divs inside the "entry" div other than those with the class "imagebrowser".

这篇关于如何使用RegEx和Jquery隐藏DIV元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆