Forum Moderators: open

Message Too Old, No Replies

innerHtml doesn't work

         

flashfan

3:47 am on Apr 13, 2004 (gmt 0)

10+ Year Member



Neither of the following innerHTML works. Don't know why. But innerText will work.
<html>
<head>
<script>
<!--
function show()
{
var h='<table border=1 border-color=red><tr><td>a</td><td>b</td></tr><tr><td>22</td><td>39</td></tr></table>';
document.getElementById("junk").innerhtml = h;
}

function hide()
{
document.getElementById("junk").innerhtml = "<font color=red>Table was hidden!</font>";
}

function text()
{
document.getElementById("junk").innertext = "Show some message.";
}
//-->
</script>
</head>
<body>
<input type=button onClick="show();" value="Show">&nbsp;&nbsp;<input type=button onClick="hide();" value="Hide">&nbsp;&nbsp;<input type=button onClick="text();" value="Text">
<div id=junk></div>
</body>
</html>

flashfan

3:54 am on Apr 13, 2004 (gmt 0)

10+ Year Member



Found the solution: innerhtml should be innerHTML. It seems case sensitive.

Rambo Tribble

1:03 pm on Apr 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JavaScript is case sensitive. Most programming languages are and now, with the advent of XML and its derivatives, so are markup languages.