-1

In the following jQuery script, I am trying to replace "2500px" with $(document).height() but it's not working.

$("#mydiv").css("cssText", "position: relative; width:30%; height:2500px!important;");

This is what I did but it's not working:

$("#mydiv").css("cssText", "position: relative; width:30%; height:"+$(document).height()+"!important;");

Am I missing something here?

user1448031
  • 2,172
  • 11
  • 44
  • 89
  • 2
    See http://api.jquery.com/css/ and http://api.jquery.com/attr/. You can use `$( "#div" ).attr( "style", "height: " + $(document).height() + "px !important;" )` – ostapische Aug 14 '14 at 08:09

1 Answers1

-1

Updated: You can use cssText like below:

$('#mydiv').css('cssText','height: 2500px !important');
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231