I have toggled my blog posts using jQuery. At the moment I can click the post title and have them all open at the same time, but I would prefer to have all posts close when another post title is clicked. What line do I need to add to my jQuery code to do this? I’ve been stuck on this for soooo long now so I’d really appreciate it if someone can help me sort this out.
Here is my code:
<script type="text/javascript">
$(document).ready(function() {
$('.toggle-section').hide();
});
</script>
<script type="text/javascript">
$(function() {
$('.entry-title').click(function() {
$(this).closest('.post').find('.toggle-section').slideToggle();
return false;
});
});
</script>
I worked up a jsfiddle here!, not sure if this is what you want, but I bet it would help.
I updated the code and fiddle to support hiding if clicking the same title