ok heres我有…它工作正常,但它寻找一个字,而不是内容。我只是想要它显示什么时候有任何内容。
$(document).ready(function(){
if ($("#Box3:contains('Product')").length) {
$('#third').show();
}
});
我不认为你需要html这个
它寻找’产品’如何让它只是寻找内容> 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 %%调用通过管理面板插入的东西。在这种情况下如果没有什么..它显示为空白空间的代码(在浏览器中查看源)。
解决方法
如果要检查文本,可以使用text()方法:
$(document).ready(function(){
if ($("#Box3").text().length > 0) {
$('#third').show();
}
});
或者对于html:
$(document).ready(function(){
if ($("#Box3").html().length > 0) {
$('#third').show();
}
});