javascript - How to set a CSS property with a variable in JQuery? -


i need set css property of width same size browser's current width. this, did var setwidth = $(window).width(), don't know how apply current code, this:

$(document).ready(function(){     $("#backgroundimg").css("width", "");  }); 

is there way this? i'm new jquery might amateur.

try this

$(document).ready(function() {     var setwidth = $(window).width();     $("#backgroundimg").css("width", setwidth + 'px');  }); 

or can use $.width

$(document).ready(function() {     $('#backgroundimg').width( $(window).width() ) }); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -