0
我有一堆这些div的,我希望他们消失,如果出售价格为$ 0.00jQuery的:从文本节点文本
<div class="ProductPriceRating">
<em>
<strike class="RetailPriceValue">$79.99</strike>
$0.00
</em>
<span class="Rating Rating0">
<img src="..." alt="" style="display: none" />
</span>
</div>
所以我写了这个jQuery
$(function(){
$(".ProductPriceRating em").contents().filter(function() {
return this.nodeType != 1;
}).wrap("<span></span>");
console.log($(".ProductPriceRating em span").text());
if($(".ProductPriceRating span").text() == ' $0.00'){
console.log('success');
$('div.ProductPriceRating').hide();
$('div.ProductActionAdd').hide();
}
});
我包在文本节点周围添加一个span标记以便于访问。然后,我将控制台记录下来,并获得“$ 0.00 $ 0.00 $ 0.00”(页面上每个元素的一个“$ 0.00”)。但没有成功。
我只是不知道我要去哪里错了
所以你不再试图获得一个跨度来自textnode的文本,你从问题标题写出的时间跨度中包含了它,现在你正在尝试做一些完全不同的事情? – adeneo