jQuery slideToggle one div at a time instead of all independently -


i'm using function below toggles divs, , it, 1 of entry-content divs can opened or closed independently of all.

what great if 1 entry-content div open @ time. clicking closed entry-title div close other entry-content div , open 1 clicked. need stay html markup, created dynamically wordpress. possible?

function:

jquery(document).ready(function($) { $(".entry-content").hide('slow'); $(".entry-title").click(function() { $(this).parent().children(".entry-content").slidetoggle(500); }); }); 

html

<div class="entry-post">     <h2 class="entry-title">post title 1</h2>     <div class="entry-content">lorem ipsum...  </div></div>     <h2 class="entry-title">post title 2</h2>     <div class="entry-content">lorem ipsum...  </div></div>  more of same....  </div> 

just close them again every time 1 clicked:

jquery(document).ready(function($) { $(".entry-content").hide('slow'); $(".entry-title").click(function() {     $(".entry-content").hide(); $(this).parent().children(".entry-content").slidetoggle(500); }); }); 

example: http://jsfiddle.net/auuxk/


Comments