shanthiram shanthiram - 1 year ago 71
jQuery Question

jquery show and hide on same link click

I have a div and I want to show and hide on a link click. Not two different links to show and hide but only one.
I have used toggle() but its not working for me..

Here is the code

<a id="showhidediv">show-hide</a>
<div id="maindiv">
<div id="innerleftdiv" style="width:49%;float:left">
<div id="innerrightdiv" style="width:49%;float:left">

<script text="text/javascript">


Answer Source

Thanks every one for trying to answer the question and every one was right..

I found the solution . The following is the jquery function

$("#showhide").click(function() { 
  if ( $("#maindiv").is(":visible") ) { 
  } else if ( $("#maindiv").is(":hidden") ) { 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download