(function(jQuery){
jQuery.fn.extend({
accordion: function() {
return this.each(function() {
var $ul = $(this);
if($ul.data('accordiated'))
return false;
$.each($ul.find('ul'), function(){
$(this).data('accordiated', true);
$(this).hide();
});
$.each($ul.find('a'), function(){
$(this).click(function(e){
//if(!$(this).hasClass('Active')) {
activate(this);
return void(0);
//}
});
});
var active = $('.Active');
if(active){
activate(active, 'toggle');
$(active).parents().show();
}
function activate(el,effect){
if (!effect) {
$(el)
.toggleClass('Active')
.parent('li')
.siblings()
.find('a')
.removeClass('Active')
.parent('li')
.children('ul')
.slideUp('fast');
}
$(el)
.siblings('ul')[(effect || 'slideToggle')]((!effect)?'fast':null);
}
});
}
});
})(jQuery);
$('.Menu.Open').accordion();
.Menu.Open is inside of .SideNav of which I want to get the new height after my accordion has collapsed/expanded content to set the height of .Main
I've been looking into timers and timed events however I just cannot get this to work after my accordion has expanded and feel my attempts are completely wrong, I'd hate to flood this page with them all!
Looking at your code, you are relying on Jquery.slideUp/slideDown to expand/collapse your accordion. If I understood you correctly you are trying to measure height after the animation is complete. I believe this is what you are looking for
$('element').slideUp('fast', function(){ perform_measurement_here();});
Also, for your reference
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.