View Full Version : Help...about InnerHTML

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


<div id="top">bla bla bla</div>
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>

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

Thanks lot friends

02-24-2007, 06: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, 06: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';


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