Using Javascript to switch between two div sections

28 07 2011

This is on.

Toggle Div Visibility

function toggleDiv(divid)
{

varon = divid + 'on';
varoff = divid + 'off';

if(document.getElementById(varon).style.display == 'block')
{
document.getElementById(varon).style.display = 'none';
document.getElementById(varoff).style.display = 'block';
}

else
{
document.getElementById(varoff).style.display = 'none';
document.getElementById(varon).style.display = 'block'
}
}

Advertisement

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.