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
Post a Comment