0
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.

3
  • 1
    No repro. Are you sure that an element with the class static exists in the DOM at the point of execution? Commented Aug 11, 2013 at 18:05
  • What does $('.static').css('width') give you? Commented Aug 11, 2013 at 18:06
  • Wath kind of elements are the ones with classes .static and .fixed? Commented Aug 11, 2013 at 18:16

1 Answer 1

2

Try with this syntax:

$('.static').css({ width : _foabgwidth + "px" }); 

or this:

$('.static').css({ width : _foabgwidth });
Sign up to request clarification or add additional context in comments.

1 Comment

That will get you the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.