Reputation: 1847
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>
Upvotes: -1
Views: 5879
Reputation: 19
Check Your syntax The document.getElementbyid('id') may not be correct may be try the syntax
element = document.getElementById(id);
Upvotes: -1
Reputation: 968
Case sensitive: document.getElementById
Try this
function expanddevice(){
document.getElementById("expandservices").innerHTML = "we have great service for iPads";
}
Upvotes: 1
Reputation: 9819
You have a typo.
try document.getElementById()
, it is case sensitive.
document.getElementById("expandservices").innerHTML = "we have great service for iPads";
Upvotes: 5