Search code examples
javascripthtmlinnerhtml

Why innerHtml doesn't work


Why doesn't innerHtml work?

<script src="jquery.js"></script>
<script type="text/javascript">
function chat()
{
    alert ("started!");
    document.getElementById("test").innerHtml="foo";
}
</script>
<body id="body" onload="chat();">
<p id="test">
test..
</p>
</body>

"started!" is showing, but the content of <p> doesn't get changed to foo as intended. Why?


Solution

  • Casing matters, it's innerHTML not innerHtml. Try this:

    document.getElementById("test").innerHTML="foo";