javascript - Cannot set property 'className' of null for and id within an id -
i getting error cannot set property 'classname' of null when trying set class name in js. js so:
setinterval(function(){ $.get('/price',function(data) { document.title = `($${data.price}) price`; document.getelementbyid("p4").innerhtml = `$${data.change}`; document.getelementbyid("p4").classname = "increase"; document.getelementbyid("p5").classname = "triangle-down"; }); }, 30000); the line in html is:
<h1 class="decrease" id="p4">$5<i class="triangle-up" id="p5"></i></h1> i same error. if comment out line below works:
document.getelementbyid("p4").innerhtml = `$${data.change}`; what doing wrong here?
you changing inside of h1 tag:
document.getelementbyid("p4").innerhtml = `$${data.change}`; what result of:
`$${data.change}` make sure above variable retuns following html: (edit: mean following format)
<h1 class="decrease" id="p4">$5<i class="triangle-up" id="p5"></i></h1>
Comments
Post a Comment