jQuery: how to "declick" a open slideToggle div? -


is possible "declick" active div has been opened slidetoggle?

this function opens multiple text divs independently each other, open div's click(function() still clickable, , div bounce closed , open again. it's user experience; i'd users unable click opened div.

jsfiddle: http://jsfiddle.net/auuxk/12/

$(".entry-content").hide(); $(".entry-title").click(function() {     $(".entry-content").hide(); $(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 lorem ipsum      </div></div>  <div class="entry-post">         <h2 class="entry-title">post title 2</h2>         <div class="entry-content">lorem ipsum  lorem ipsum  lorem ipsum       </div></div> 

i think want. seems people didn't notice want keep 1 open div @ time.

http://jsfiddle.net/entropo/wnpgv/

jquery(document).ready(function($) {     $(".entry-title").click(function() {         $this = $(this);         var $content = $this.next(".entry-content");         if (! $content.is(":visible")) {             $(".entry-content:visible").slidetoggle(100);             $content.slidetoggle(500);         }     }); }); 

edit:
ui pattern called accordion. there lots of plugins achieve in more dramatic/complicated ways.

also, jquery ui has accordion in api. keep in mind accordion api is being revamped 1.9.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -