如果div有内容显示的div [英] if div has content show div
问题描述
确定继承人我有什么...它工作正常,但它看起来一个词,而不是内容。我只是想让它显示,当存在任何内容。
ok heres what i have... it works fine but it looks for a word rather than content. i just want it to show when there is any content..
$(document).ready(function(){
if ($("#box3:contains('Product')").length) {
$('#third').show();
}
});
我不认为你需要为这个HTML的
i dont think you need the html for this
它看起来对产品我如何让它随便找含量> 0
it looks for 'Product' how do i make it just look for content >0
<div id="first" class="tab" >
<div class="tabtxt">
<a>DETAILS</a>
</div>
</div>
<div class="tab" id="second">
<div class="tabtxt">
<a>INSPIRATION</a>
</div>
</div>
<div class="tab" id="third" style="display:none">
<div class="tabtxt">
<a>NOTES</a>
</div>
</div>
<div class="boxholder">
<div style="overflow: hidden; display:block" class="box" id="box1">
<div style="padding: 10px; line-height:16px">
%%Panel.ProductDescription%%
</div>
</div>
<div style="overflow: hidden; display:none" class="box" id="box2">
<div style="padding: 10px; line-height:16px">
%%Panel.ProductWarranty%%
</div>
</div>
<div style="overflow: hidden; display:none" class="box" id="box3">
<div style="padding: 10px; line-height:16px">
%%Panel.UPC%%
</div>
</div>
</div>
它的interspire购物车所以%% panel.upc的东西通过管理面板插入%%调用。在这种情况下,如果有什么..它显示了code为空白空间(在浏览器中查看源)。
its an interspire shopping cart so the %%panel.upc%% calls in something inserted through the admin panel. in this case if there is nothing.. it shows as blank space in the code (viewing source in browser).
推荐答案
如果您要检查文字上,您可以使用文本()
方法:
If you want to check for text, you can use the text()
method:
$(document).ready(function(){
if ($("#box3").text().length > 0) {
$('#third').show();
}
});
或为HTML:
$(document).ready(function(){
if ($("#box3").html().length > 0) {
$('#third').show();
}
});
这篇关于如果div有内容显示的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!