dom - How can I change the text using JavaScript -


this question has answer here:

<div class="baseprice">$99.99</div> 

i want change value $99.99 using javascript.

i tried using getelementbyclass didn't produce results hoping get.

document.getelementsbyclass returns nodelist, kind of array.

you have specify element (there's 1 here, i'm assuming first) you're looking for, , can use .textcontent change text of node.

document.getelementsbyclassname("baseprice")[0].textcontent = "$49.99"; 

document.getelementsbyclassname("baseprice")[0].textcontent = "$49.99";
<div class="baseprice">$99.99</div>


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -