javascript - Customise jQuery Accordion -
i'd following:
1) open first box default & 2) close box when clicked. right closes & re-opens instantly.
demo: http://jsfiddle.net/2hmzcgqm/
(function($) { var allpanels = $('.accordion > dd').hide(); $('.accordion > dt > a').click(function() { allpanels.slideup(); $(this).parent().next().slidedown(); return false; }); })(jquery);
1) add line after click
handler:
$('.accordion > dt > a').first().trigger('click');
2) add line @ second line of click
handler:
if ($(this).parent().next().is(":visible")) return false;
so:
$('.accordion > dt > a').click(function() { allpanels.slideup(); if ($(this).parent().next().is(":visible")) return false; $(this).parent().next().slidedown(); return false; }); $('.accordion > dt > a').first().trigger('click');
updated fiddle
Comments
Post a Comment