Ale*_*lex 35 html jquery animation
好吧继承人我有...它工作正常,但它寻找一个词而不是内容.我只是希望它显示何时有任何内容..
$(document).ready(function(){
if ($("#box3:contains('Product')").length) {
$('#third').show();
}
});
Run Code Online (Sandbox Code Playgroud)
我不认为你需要这个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>
Run Code Online (Sandbox Code Playgroud)
它是一个interpire购物车,所以%% panel.upc %%调用通过管理面板插入的东西.在这种情况下,如果没有...它在代码中显示为空白(在浏览器中查看源).
Sar*_*raz 63
如果要检查文本,可以使用以下text()方法:
$(document).ready(function(){
if ($("#box3").text().length > 0) {
$('#third').show();
}
});
Run Code Online (Sandbox Code Playgroud)
或者对于html:
$(document).ready(function(){
if ($("#box3").html().length > 0) {
$('#third').show();
}
});
Run Code Online (Sandbox Code Playgroud)
Nic*_*ver 15
对于更新的问题:检查内部的修剪文本<div>,如下所示:
if ($.trim($("#box3 div").html())) {
$('#third').show();
}
Run Code Online (Sandbox Code Playgroud)
前面的回答:如果你想显示如果有什么,然后检查:not()对:empty作品:
if ($("#box3:not(:empty)").length) {
$('#third').show();
}
Run Code Online (Sandbox Code Playgroud)
如果要检查任何元素(不仅仅是空格),请使用:has(*),如下所示:
if ($("#box3:has(*)").length) {
$('#third').show();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
91503 次 |
| 最近记录: |