Reputation: 845
I want to pass the following variable like so:
var $headerHeight = jQuery("#header").outerHeight() - jQuery("#header .main-menu").outerHeight();
jQuery(this).find('nav').attr('style', 'margin-top:' + $headerHeight + '!important');
It's obviously used in the wrong syntax; I just can't figure out how to use it correctly. The jQuery ".css" function isn't an option because it has to have the "!important" declaration. How can I pass $headerHeight
in the above example?
Upvotes: 0
Views: 187
Reputation: 95030
You're fixing the wrong problem. Instead of un-doing a change that slideToggle does, simply don't use slideToggle.
$(myelement).animate({
height: "200px" // or whatever your target height is, calculated or static.
},500/*duration*/);
Upvotes: 0
Reputation: 1171
var headerHeight = $("#header").outerHeight() - $("#header .main-menu").outerHeight();
jQuery(this).find('nav').attr('style', 'margin-top:' +headerHeight+'px ' + '!important');
Upvotes: 1