var acordeonH1Seleccionado; function getAcordeonH1Seleccionado() { return acordeonH1Seleccionado; } ( function($) { $.fn.accordion = function(options) { return this.each(function() { var settings = $.extend( { firstChildExpand: true, multiExpand: false, slideSpeed: 500, dropDownIcon: '▼' }, options ); $(this).children("h1").each( function() { $(this).next('div').andSelf().wrapAll("
"); } ); $(this).children().children('div').addClass("accordion1-content"); $(this).find("h1").wrap(""); $(this).find("h1").after(""); $(this).children('.accordion1-item').wrap(''); if(settings.firstChildExpand==true) { $(this).find(".accordion1-header:first").toggleClass("accordion1-header-active"); $(this).find(".accordion1-header:first").parent().toggleClass("accordion1-item-active"); $(this).find(".accordion1-header:first").next().slideToggle(0); $(this).find(".accordion1-header:first").children(".accordion1-header-icon").toggleClass("accordion1-header-icon-active"); } $(this).find(".accordion1-header").click( function() { acordeonH1Seleccionado = $(this).find("h1").attr('id'); if(settings.multiExpand==false){ if(!$(this).hasClass('accordion1-header-active')) { $(this).parent().parent().parent().find(".accordion1-header-active").removeClass('accordion1-header-active'); $(this).parent().parent().parent().find(".accordion1-item-active").children(".accordion1-content").slideUp(settings.slideSpeed); $(this).parent().parent().parent().find(".accordion1-header-icon-active").removeClass("accordion1-header-icon-active"); $(this).parent().parent().parent().find(".accordion1-item-active").removeClass("accordion1-item-active"); } } $(this).toggleClass("accordion1-header-active"); $(this).parent().toggleClass("accordion1-item-active"); $(this).next().slideToggle(settings.slideSpeed); $(this).children(".accordion1-header-icon").toggleClass("accordion1-header-icon-active"); } ); }); } } (jQuery));