Javascript innerHTML help

Tom743

New Member
Messages
72
Reaction score
0
Points
0
I'm a noob at javascript and I'm trying to get the text "Hi" to appear when I click the link, but its not working. Does anyone know why?

HTML:
<a href="javascript: document.getElementById(text).innerHMTL = 'Hi';">View</a>
<div id="text"></div>
 

sybregunne

Member
Messages
54
Reaction score
0
Points
6
try putting quotes on document.getElementById("text").innerHTML
That should make it work.
 

sunils

New Member
Messages
2,266
Reaction score
0
Points
0
just change the order and try like this

<div id="text"></div>
<a href="javascript: document.getElementById("text").innerHMTL = 'Hi';">View</a>
 
Top