javascript - Can't alter element's html after selecting it with querySelector -
i trying change html in div using queryselector, it's not working.
html:
<div class="test"> <p>par1</p> <p>par2</p> <p>par3</p> </div>
js:
var d = document.queryselector('.test'); var d.innerhtml = '<p>works</p>';
just remove var
keyword before d.innerhtml
, property, not variable. code:
var d = document.queryselector('.test'); d.innerhtml = '<p>works</p>';
Comments
Post a Comment