473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2415
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so...
1
by: Thomas | last post by:
It looks like the String.replace doesn't work in IE6.1. Anyone else has the same problem. I am using newest service package of IE and Win2K. Thanks
6
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with...
2
by: Barnes | last post by:
Hi, Can anyone please tell me how I can use the replace method to replace a character if it occures in more than one textbox without having to write separate function for each textbox. The...
5
by: Cristian Tarsoaga | last post by:
Hi there! I'm a javascript begginner, and I wrote a small piece of code that uses the replace and the eval methods. When calling them separately, they seem to work and everything is ok. But...
0
by: Joord | last post by:
Dear all, I'd like to do something which is easy in Jscript, but I can't figure it out how to do it in c#. In javascript I can put an function inside an regex Replace like this: var a="<td...
5
by: Casey | last post by:
Hello, Can someone give me specific code to replace text on a page using server side javascript? I need to use server-side because I need the output to be recognized in the final HTML so that...
12
by: Michael | last post by:
In PHP there is a function called str_replace (http://php.net/str_replace). Basically you can freed in two strings and a "subject" string. Then it goes through the subject string searching for...
5
by: V S Rawat | last post by:
I was trying to use back-to-back replace functions to convert a url: str1 = str.replace("%2F","/").replace("%3F","?").replace("%3D","=").replace("%2 6","&"); It didn't replace all 4 types of...
9
by: Mark Szlazak | last post by:
I don't think this is "do-able" but thought I'd better check. Say I want to replace certain names in some source code as long as they are not properties (dot properties) of objects. I could use a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.