<span class="woocommerce-Price-amount amount"> <bdi> <span class="woocommerce-Price-currencySymbol">RM</span> "678" </bdi> </span>
How can i target only the number of this bdi without the currency simble with Javascript?
Advertisement
Answer
Update a child node’s textContent
. Depending on the currency, the index will be either 1 or 2. In your case it’s 2, because the currency symbol is before the amount.
example:
document.querySelector(".woocommerce-Price-amount bdi").childNodes[2].textContent = '1000';
The index 0 is skipped because it is a node with a newline character (thanks @derprischer).