Reputation: 21617
var _headerwidth = $('#header').width();
var _foabgwidth = $('#page-body-inner').width();
console.log(_headerwidth);
console.log(_foabgwidth);
$('.static').css("width",_foabgwidth + "px");
$('.fixed').css("width",_headerwidth + "px");
var staticwidth = $('.static').width();
console.log('staticwidth:'+staticwidth);
Using the above code, my console logs are as follows
940
676
staticwidth:null
I'm trying to set the width for .static
and fixed
and I'm unable to get it to work using the jQuery I've used.
Upvotes: 0
Views: 6621
Reputation: 1938
Try with this syntax:
$('.static').css({ width : _foabgwidth + "px" });
or this:
$('.static').css({ width : _foabgwidth });
Upvotes: 2