Link to home
Start Free TrialLog in
Avatar of prabhualla
prabhuallaFlag for India

asked on

How to expanding and collapsing a division using JavaScript/jquery

Dear Experts,

I am new to JavaScript, i want to implement a task that, hide/show or expanding/collapsing a division using javascript / jquery.

Kindly provide the required code.
ASKER CERTIFIED SOLUTION
Avatar of Gregg
Gregg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Plain javascript:

function Toggle(id) {
  var o=document.getElementById(id);
  o.style.display = (o.style.display == 'none') ? 'block' : 'none';
}

Open in new window


Usage:

<button onclick="Toggle('TheDiv')">On/off</button>
<div id="TheDiv">Hello!</div>

Open in new window

Avatar of prabhualla

ASKER

thanks for the solution
Did you try my code?