...

View Full Version : Help...about InnerHTML



ershad
02-24-2007, 08:52 AM
sorry, i cant speak english well..
I have problem..

example..

<html>
<body>
<div id="top">bla bla bla</div>
<script>
document.getElementById('top').innerHTML='<div>new content top</div>';
document.getElementById('bottom').innerHTML='<div>new content bottom</div>';</script>
<div id="bottom">bla bla bla</div>
</body>
</html>

the blue script is not working.,.
i wanna the blue script still working without changing the position ( above div bottom )

Thanks lot friends

BubikolRamios
02-24-2007, 05:21 PM
I can't see any reason why u perist having script there. If u leave it there it won't work.

to sumarize, why you want to put 'new content bottom' when there is no 'previous content bottom'? You do actualy have something there, but it is not displayed to user , so there is no use of it.

Mr J
02-24-2007, 05:24 PM
The bottom div is not changed because the script is run before that element has been rendered

Try it this way



<script type="text/javascript">

onload=function test(){
document.getElementById('top').innerHTML='new content top';
document.getElementById('bottom').innerHTML='new content bottom';
}

</script>

<div id="top">bla bla bla</div>
<div id="bottom">bla bla bla</div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum