I am trying to add !important in the css attribute using jQuery like
but !important has no effect. How to include !important in jquery?
You don't need !important when modifying CSS with jQuery since it modifies the style attribute on the elements in the DOM directly. !important is only needed in stylesheets to disallow a particular style rule from being overridden at a lower level. Modifying style directly is the lowest level you can go, so !important has no meaning.
Apparently it's possible to do this in jQuery:
$("#tabs").css("cssText", "height: 650px !important;");
I solved this problem with:
inputObj.css('cssText', inputObj.attr('style')+'padding-left: ' + (width + 5) + 'px !IMPORTANT;');
So no inline-Style is lost, an the last overrides the first
It is also possible to add more important properties:
inputObj.attr('style', 'color:black !important; background-color:#428bca !important;');