Collapsing a custom jquery accordion on load -
there custom accordion came html theme i'm modifying , want figure out how collapse them on load (or have third option open on load; either 1 works).
(function() { var $container = $('.acc-container'), $trigger = $('.acc-trigger'); $container.hide(); $trigger.first().addclass('active').next().show(); var fullwidth = $container.outerwidth(true); $trigger.css('width', fullwidth); $container.css('width', fullwidth); $trigger.on('click', function(e) { if( $(this).next().is(':hidden') ) { $trigger.removeclass('active').next().slideup(300); $(this).toggleclass('active').next().slidedown(300); } e.preventdefault(); }); // resize $(window).on('resize', function() { fullwidth = $container.outerwidth(true) $trigger.css('width', $trigger.parent().width() ); $container.css('width', $container.parent().width() ); }); })();
jquery not strength @ all, on setting make me happy!
if remove, or change:
$trigger.first().addclass('active').next().show();
to
$trigger.get(2).addclass('active').next().show();
this should select 3rd 1 open, or remove line keep them collapsed.
Comments
Post a Comment