so I have the following code:
<div class="price price--reduced"> <span class="price__currency">€</span> 56,05 <span class="price__old"> <span class="price__currency">€</span> 59,00 </span> </div>
I am trying to get the 56,05 and write it into a variable. I can only use JS here. What I wrote so far is:
var element = document.querySelector(".price.price--reduced"); var text = element.innerHTML; text = text.replace(/</?span[^>]*>/g,"");
The problem now is that the result I get is
€ 56,05€ 59,00. What I would like to do is not just remove the span from the string but everything it contains as well, only leaving me with the
56,05. I couldn’t find the same issue anywhere so maybe you could tell what I miss here.