Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    58
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Using innerHTML to change a DIV's text

    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.

    Code:
    <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

  • #2
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you misstyped innerHTML. what you have posted is innerHMTL :P

  • #3
    New Coder
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    58
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Damn, I copied and pasted that from a forum post!

    Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •