Page 1 of 1

!important from JS to an inline style.

Posted: Wed Aug 19, 2009 5:46 am
by lovelf
Hi, I'm trying to do:

Code: Select all

var xVar=100; ..... xVar+='px'; document.getElementById("elementId").style.height=xVar+'!important';
to override an !important set on the element with CSS,

Code: Select all

<textarea style="height:40px!important;"></textarea>
The !important doesn't fit in this way, is there a possible way?

Re: !important from JS to an inline style.

Posted: Wed Aug 19, 2009 10:02 am
by Reviresco
This might do it (not sure if I got the syntax right):

Code: Select all

document.getElementById('elementId').style.setProperty("height", xVar, "!important");