-2

The span tag with class="WooZone-free-shipping" has an & character just inside it. I cannot remove it from the code for some reason but I have to hide it on this page. I tried to do it with the following jQuery:

jQuery('.WooZone-free-shipping').html(jQuery('.WooZone-free-shipping').html().replace("&",""));

and with this css:

span.WooZone-free-shipping:nth-child(1) {
    display: none;
}

But these two methods did not work.

enter image description here

Rahul
  • 493
  • 6
  • 27
  • Afaik, you cannot apply css to individual characters within a text node. It's all or nothing. – Taplar Mar 14 '18 at 17:29
  • You might want to try text-indent with a negative value. Use with caution, and if it's a link, don't do it as it could negatively affect your site in terms of SEO (it's frowned at by Google and other search engines). – Luis Serrano Mar 14 '18 at 17:34
  • @LuisSerrano it's not a link. – Rahul Mar 14 '18 at 17:37

1 Answers1

1

html() will convert & to amp. You need to use text while replacing

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&amp;D</div>
Sanchit Patiyal
  • 4,910
  • 1
  • 14
  • 31