Subject: Access div content
Posted By: mattastic Post Date: 11/17/2004 9:25:15 AM
Hi I'm tryin to get the following code to work but I'm having a few problems, I need to dynamically change the content of the div:

<script lanuage="javascript">
document.getElementById("w00t").innerhtml = "lkkjkhkjhkj";
</script>
<div id="w00t"></div>

Hope you can help.

Reply By: ChrisScott Reply Date: 11/17/2004 9:29:11 AM
Try .innerHTML

HTH,

Chris

Reply By: mattastic Reply Date: 11/17/2004 9:35:28 AM
Thanks for your repl but I'm still having problems:

<html>
<head>
<script language = "javascript">
document.getElementById("w00t").innerHTML = "testing";
</script>
</head>
<body>
<div id="w00t"></div>
</body>
</html>


Reply By: ChrisScott Reply Date: 11/17/2004 9:40:17 AM
The trouble is that the div has not yet been added to the page when your are trying to access it in your script.

A couple of possibilities are to move the script to later in the page (after the div tag) or put it in a function & execute it when the body onload event fires.

Cheers,

Chris


Go to topic 22201

Return to index page 713
Return to index page 712
Return to index page 711
Return to index page 710
Return to index page 709
Return to index page 708
Return to index page 707
Return to index page 706
Return to index page 705
Return to index page 704