...

View Full Version : Using innerHTML to change a DIV's text



seanhalley
09-09-2010, 11:51 AM
Hi all,

Hope you can help with the following. I'm trying to change the contents of DIV2 when I click on DIV1. The following code doesn't work for some reason. I'm using Windows 7 (64-bit), and testing on Firefox 3.6.8 and IE8.



<html>
<head>
<script type="text/javascript" language="javascript">

function test() {

document.getElementById("test2").innerHMTL="hello";

}

</script>
</head>
<body>

<div id="test1" style="border: 1px solid #ff0000; width: 200px; height: 100px;" onclick="test();">Test Box 1</div>
<div id="test2" style="border: 1px solid #ff0000; width: 200px; height: 100px;">Test Box 2</div>

</body>
</html>


Any help appreciated,

Cheers
Sean

SydarGr
09-09-2010, 12:12 PM
you misstyped innerHTML. what you have posted is innerHMTL :P

seanhalley
09-09-2010, 12:26 PM
Damn, I copied and pasted that from a forum post!

Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum