Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

How to force set he height of an element using jquery

HI,
I am using the following code to set the height of the element in jquery :
                   $('.cke_contents').css('height', middleHeight - toolbarHeight);

But the issue is there is already a css rule which sets height to some 100px !important because of this important thing my changes to height using .css function are not getting applied. So one way out of this i think is somehow add !important to the .css function ??

Or there is any other alternative way ?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Russ Suter
Russ Suter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What are the values for middleHeight and toolbarHeight. If these are string values with unit indicators, the calculation would generate an unexpected result. Have you checked that the calculation is working properly?
console.log('Calculated height = ' + (middleHeight - toobarHeight) );

Open in new window

Avatar of Rohit Bajaj

ASKER

Hi,
the values are just numbers like 300 or 100.
Also i read up that cssText clears everything else... so if any other styling info was there on the element it will clear that up..whereas in my case i only want to adjust the height
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Russ Suter
Russ Suter

Indeed, my test confirms that what Kim posted should work.