Monday, 28 November 2011
Set "!important" style by JavaScript
It is very easy to set style in any DOM element by Javascript like:
var target = document.getElementById('MyDiv');
target .style.marginleft ="100px";
But if you want to add "!important" like this -
target .style.marginleft ="100px !important";
this will not work.
Use this code to get it done.
target.setAttribute('style', 'margin-left:200px !important');
Subscribe to:
Posts (Atom)