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

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -