javascript - Add Easing effect to Accordion Opening / Closing -


i'm super new js wanted simple accordion built one. reason @ loss when trying add easing effect opening / closing of it. appreciated. thank you!

codepen of accordion

js code:

(function(){ // class added expanded item var activeitemclass = 'accordion-expanded'; var accordionitemselector = '.accordion-section'; var toggleselector = '.accordion-head';  $(toggleselector).on('click', function() {       $(this)         .closest(accordionitemselector) // go accordion item element         .toggleclass(activeitemclass)             .siblings()             .removeclass(activeitemclass); });  })(); 

since you're using jquery, why not this:

var accordionitemselector = '.accordion-body'; var toggleselector = '.accordion-head';  $(toggleselector).on('click', function() {    if (!$(this).next(accordionitemselector).is(":visible"))     $(toggleselector).not($(this)).next(accordionitemselector).slideup();   $(this).next(accordionitemselector).slidetoggle();    }); 

updated pen


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -