469,356 Members | 2,055 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Replace javascript div

Hi

I am a beginner in javascript. I have a small problem.
I have the following html code :
Code:

<tr> <td> <div id = div> html1 </div> </td></tr>
<tr> <td> <div id = div2> html2 </div> </td></tr>

I would like to replace what's html1 by html2 and html2 by html1 every
x seconds. how can I do that?

Thanks :)

Apr 7 '06 #1
1 2372
wrote on 07 apr 2006 in comp.lang.javascript:
Hi

I am a beginner in javascript. I have a small problem.
I have the following html code :
Code:

<tr> <td> <div id = div> html1 </div> </td></tr>
<tr> <td> <div id = div2> html2 </div> </td></tr>

I would like to replace what's html1 by html2 and html2 by html1 every
x seconds. how can I do that?


The table elements are not important here.
Try this for once every 1000 miliseconds:

=======================================

<div id = div1> html1 </div>
<div id = div2> html2 </div>

<script type='text/javascript'>

var div1 = document.getElementById('div1')
var div2 = document.getElementById('div2')

function swapdDivs(){
var temp = div2.innerHTML
div2.innerHTML = div1.innerHTML
div1.innerHTML = temp
}

setInterval('swapdDivs()',1000)

</script>

========================================
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Cristian Tarsoaga | last post: by
reply views Thread by Joord | last post: by
5 posts views Thread by Casey | last post: by
12 posts views Thread by Michael | last post: by
9 posts views Thread by Mark Szlazak | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.