javascript for expand and colapse

iam using C# code,i want javascript for expand/colapse , when we click on an item that will be expanded and other all expanded item should be colapsed, only the clicked item should be expanded.please help me how can i do this??
Who is Participating?
u can find the script of collapse and expand on

just search here in this site, i am sure u will get it.
here in this ajax will be used, you can get its complete tutorial on microsoft website

just type ajax videos in google and u will find the first link darkened. please go there.
ninusajilAuthor Commented:
sorry, i not like to use ajax for this, will u pls help using javascript for this
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Sreedhar VengalaSr. Consultant - Business IntelligenceCommented:
You should be able to expand on this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Expand / Colapse Div</title>
<script type="text/javascript">
function toggle2(id, link) {
  var e = document.getElementById(id);
  if ( == '') { = 'none';
    link.innerHTML = 'Expand';
  } else { = '';
    link.innerHTML = 'Collapse';
<body bgcolor="Background">
<a href="#" onclick="toggle2('content', this)">Collapse</a>
<div id="content" style="display:none">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc fermentum.

Open in new window

expand a collapse what?
ninusajilAuthor Commented:
sorry for the late respose, i am  not well for some days.....

i tried this

this is working but when i expand any one and goes to some other page and returns back the expanded item expand as it is not colapsing
i want collapse all when i took that page
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.