I Like
I Like

Reputation: 1847

.innerHTML not showing up

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

Answers (4)

Nekta Point
Nekta Point

Reputation: 19

Check Your syntax The document.getElementbyid('id') may not be correct may be try the syntax

element = document.getElementById(id);

Upvotes: -1

Nitya Kumar
Nitya Kumar

Reputation: 968

Case sensitive: document.getElementById

Try this

function expanddevice(){

    document.getElementById("expandservices").innerHTML = "we have great service for iPads";
}

Upvotes: 1

Randy
Randy

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

Edward Hu
Edward Hu

Reputation: 57

Try .text or .value because .innerHTML is for divs and spans.

Upvotes: -1

Related Questions