Javascript 如何使用jquery隐藏div

Javascript 如何使用jquery隐藏div,javascript,jquery,Javascript,Jquery,如果div包含的标签设置为0,我只想隐藏div 这是我的设计: <div id="pnltickethistory" class="thumb"> <img alt="" src="../images/emblem-library_64.png" name="ibtninquiryhistory" width="64" height="64" /> <br/> <asp:LinkButton ID="lbut_inquiry_hi

如果div包含的标签设置为0,我只想隐藏div

这是我的设计:

<div id="pnltickethistory" class="thumb">
    <img alt="" src="../images/emblem-library_64.png" name="ibtninquiryhistory" width="64" height="64" />
    <br/>
    <asp:LinkButton ID="lbut_inquiry_histrory" runat="server" onclick="lbut_inquiry_histrory_Click">Enquiry History</asp:LinkButton>
    <div class="noti_bubble" id="noti_bubble1">
        <asp:Label ID="lbl_inquiry_count" runat="server"></asp:Label>
    </div>
</div>
如何使用jquery隐藏div 假设
noti\u bubble3
是要隐藏的
div的类名

简单地说

$('.noti_bubble3').css('display', 'none'); // hide elements with class .noti_bubble3    
或者

供参考:

.css( property ) // will return property value
.css( property, value ) // will set property value

根据评论进行编辑, 或者

或者

参考而不是
.css('none')
,使用
.css(“display”,“none”)


然后继续阅读。

use可以使用
$(“…”).hide()

要使用jquery隐藏某些内容,可以使用内置的隐藏方法:

$('your_selector').hide()
尝试或尝试其他方法。例如:

$('#my_div').hide();


请试试这个。选择具有指定属性且值正好以给定字符串开头的元素

$("[id^= 'noti_bubble']").hide();

假设标签具有文本内容“0”时设置为0。然后您可以使用以下代码:

$('.noti_bubble').each(function() {
     var el = $(this).find('Label');
     if (!el.length) return true;
     var v = el.text();
     if (v == '0') $(this).hide();
});

好的,我得到了解决方案,只需将runat=“server”添加到想要隐藏的div中,您只需从代码隐藏中使用这个div,并使Visible=false

请使用有意义的变量名,并让工具将其最小化:)我在这里使用这种技术,我只想用它的id隐藏div。上面的jquery从标签中取值是否正确?@shal如果
noti_bubble3
是您的
id
只需更改选择器并使用
$(''noti_bubble3')。hide()到hide@shal什么是
$('#')
?。这是无效的selector@shal
$(“#label_id”)
-->选择id为的标签
“label_id”
让我们来看看如何找到简单的标签。按类选择“id”或“id.ClientID”比按idia选择更灵活,但我想隐藏内部标签值为0的div。在这里,我有三个类为noti_bubble的div,我必须检查每个包含0值的标签,然后用div id隐藏它。
$('#noti_bubble3').css('display', 'none'); // hide element with ID noti_bubble3
$('#noti_bubble3').hide();
$('#noti_bubble3').toggle();
$('your_selector').hide()
$('#my_div').hide();
$('#my_div').fadeOut();
$("[id^= 'noti_bubble']").hide();
$('.noti_bubble').each(function() {
     var el = $(this).find('Label');
     if (!el.length) return true;
     var v = el.text();
     if (v == '0') $(this).hide();
});