jquery - Closing custom selectbox when opening a new one -


i've decided make working jsfiddle example make easy suggestions.

i have custom button toggles down list. functions <select> input can styled way i'm needing. need write logic jquery close other open select boxes if go click new one.

i have every other scenario of needing close select box taken care. code below.

jsfiddle: working example here

can modify js close .not() select box being clicked?

if using active status classes target active selectbox , close down, proceed rest

$(this).children('.btn.select').click(function(){      $('.active').next('.options').slideup('regular'); // close active 1      if ($(this).next('.options').is(':hidden')){         $(this).next('.options').slidedown('regular');         $(this).addclass('active');     } else {         $(this).next('.options').slideup('regular');         $(this).removeclass('active');     }     return false }); 

i reduce selector mess , animation duration, make code prettier , cleaner:

$(this).children('.btn.select').click(function(){        $('.options').slideup(800); // close active 1     $options = $(this).next('.options');      if ($(this).hasclass('active')){         $options.slidedown(800);         $(this).addclass('active');     } else {         $options.slideup(800);         $(this).removeclass('active');     }     return false }); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -