Forum Moderators: open

Message Too Old, No Replies

Show & Hide Multiple Divs

With more than one group

         

limbo

2:15 pm on Jul 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi

I have been very impressed with Bernard's script here: [webmasterworld.com...]

It works well for a single group of divs but falters when there are more than one group.

Basically I want to be able to change a variety of div contents across a whole range of divs within one page

The HTML looks a little like this:

<div id="item-1"></div>
<ul>
<li><a href="#">item-1a</a></li>
<li><a href="#">item-1b</a></li>
<li><a href="#">item-2c</a></li>
</ul>

<div id="item-2"></div>
<ul>
<li><a href="#">item-2a</a></li>
<li><a href="#">item-2b</a></li>
<li><a href="#">item-2c</a></li>
</ul>

So the links 1a-1c & 2a-2c change the div contents of the corresponding div above.

Anyone got a script that will allow multiple div swapping?

Cheers, Limbo

lobo235

4:00 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



Changing DIV content:

function divFill( toId, fromId ) {
var fromDiv = document.getElementById( fromId );
document.getElementById( toId ).innerHTML = fromDiv.innerHTML;
}

Just setup a bunch of hidden divs with the content you want to put into your main div. This way the content will still be spidered by the search engines.