HTML
<p class="heading"></p>
<div id="div1" class="targetDiv">content1</div>
<p class="heading"></p>
<div id="div2" class="targetDiv">content2</div>
<p class="heading"></p>
<div id="div3" class="targetDiv">content3</div>
<p class="heading"></p>
<div id="div4" class="targetDiv">content4</div>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".targetDiv").hide();
//toggle the componenet
jQuery(".heading").click(function()
{
jQuery(this).next(".targetDiv").slideToggle(500);
});
});
</script>
here i’m able to show one div on clicking heading but when i’m going to open another it must get hidden. Infact while i’m opening one div other must get hidden.
pls help me…
Thanks in advance
This should do the trick:
A small explanation: It first hides all divs and then opens one. I should do so fast that you won’t be able to see it.