tags:

views:

53

answers:

1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11//DTD/xhtml11.dtd"&gt;

<html xmlns = "http://www.w3.org/1999/xhtml"&gt;
<head>
<title>Dom demo</title>
<script type="text/javascript">
function changeText()
{
document.getElementById('first').innerHTML="Second Entry";
document.getElementById('second').innerHTML="First Entry";
}
</script>
</head>
<body>

<div id="first">First Entry</div>
<div id="second">Second Entry</div>
<input type="button" onclick="changeText()" value="Change text of this document">
</body>
</html>
A: 
function changeText()
{
    var temp;
    temp = document.getElementById('first').innerHTML;
    document.getElementById('first').innerHTML=document.getElementById('second').innerHTML;
    document.getElementById('second').innerHTML=temp;
}

I'm not sure if that is what you wanted but that will allow you to continuously swap values between the divs.

Andrew Dunn
A jsFiddle that does the above ==> http://jsfiddle.net/qv6s9/
Peter Ajtai