I've searched many related stack overflow questions, but can't understand why my .innerHTML
is not working. I created a javascript file and while alert
seems to be working fine, the .innerHTML
doesn't.
function expanddevice(){
alert('huh?');
document.getElementbyId("expandservices").innerHTML = "we have great service for iPads";
}
<div class="imgDescription">
<span><a href="#socialmedia">Devices</a></span>
<div class="imgcontainer">
<img onClick="expanddevice()" src="pics/device.png">
</div>
</div>
<p id="expandservices">Text should appear here:</p>
You have a typo.
try document.getElementById()
, it is case sensitive.
document.getElementById("expandservices").innerHTML = "we have great service for iPads";