Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to target only the number of this with javascript

<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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading