!important from JS to an inline style.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

!important from JS to an inline style.

Post 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?
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: !important from JS to an inline style.

Post 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");
Post Reply