toggle open too many elements
I have a series of divs with internal divs. I want only the internal divs of the clicked parent to open.
With my code all the internal divs of all the parent divs open at the same time.
I think I should be using (this) to target just the children of the parent div but I can't get the code right.
Also, I want all the internal divs to be closed when the page loads but my code is not doing this either.
You ave probably guessed I am a beginner!
Help gratefully appreciated.
- <div id="yacht01" class="toggleLink">
<h2>Yacht 1</h2>
<div class="description " >
<h2>Description</h2>
<p>Content Here</p>
</div>
<div class="images " >
<h2>Images</h2>
<p>Content Here</p>
</div>
<div class="equipment ">
<h2 >Extras</h2>
<p>Content Here.</p>
</div>
</div>
<div id="yacht02" class="toggleLink">
<h2>Yacht 2</h2>
<div class="description " >
<h2 >Description </h2>
<p>Content Here</p>
</div>
<div class="images " >
<h2>Images</h2>
<p>Content Here</p>
</div>
<div class="equipment ">
<h2>Extras</h2>
<p>Content Here</p>
<div >
</div>
</div>
</div>
- <script type="text/javascript">
$(document).ready(function(){
$(".description, .images, .equipment").addClass("close");
$(".toggleLink").click(function () {
$(".description, .images, .equipment").toggle("slow");
});
});
</script>