class="WooZone-free-shipping"
的范围标记内部有&
个字符。我出于某种原因无法将其从代码中删除,但我必须将其隐藏在此页面上。
我试着用以下jQuery做到这一点:
jQuery('.WooZone-free-shipping').html(jQuery('.WooZone-free-shipping').html().replace("&",""));
并使用此css:
span.WooZone-free-shipping:nth-child(1) {
display: none;
}
但这两种方法都不起作用。
答案 0 :(得分:1)
html()
会将&
转换为amp
。您需要在替换
text
console.log("TEXT - "+jQuery('.WooZone-free-shipping').text());
console.log("HTML - "+jQuery('.WooZone-free-shipping').html());
jQuery('.WooZone-free-shipping').html(jQuery('.WooZone-free-shipping').text().replace("&",""));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="WooZone-free-shipping">ABC&D</div>