Title pretty much sums it up.
The external style sheet has the following code:
td.EvenRow a{
display: none !important;
}
I have tried using:
element.style.display = "inline";
and
element.style.display = "inline !important";
but neither works. Is it possible to override an !important style using javascript.
This is for a greasemonkey extension, if that makes a difference.
There are a couple of simple one-liners you can use to do this.
1) Set a "style" attribute on the element:
or...
2) Modify the
cssText
property of thestyle
object:Either will do the job.
===
BTW - if you want a useful tool to manipulate
!important
rules in elements, I've written a jQuery plugin called "important": http://github.com/premasagar/importantIf you want to update / add single style in DOM Element style attribute you can use this function:
style.cssText is supported for all major browsers.
Use case example:
Here is link to demo
element.style
has asetProperty
method that can take the priority as a third parameter:It didn't work in old IEs but it should be fine in current browsers.
Better method I just discovered: try to be more specific than the page CSS with your selectors. I just had to do this today, and it works like a charm! More info on the W3C site: http://www.w3.org/TR/CSS2/cascade.html#specificity
Below is a snippet of code to set the important parameter for the style attribute using jquery.
Usage is pretty simple.Just pass an object containing all the attributes you want to set as important.
There are two additional options.
1.To just add important parameter to already present style attribute pass empty string.
2.To add important param for all attributes present dont pass anything. It will set all attributes as important.
Here is it live in action. http://codepen.io/agaase/pen/nkvjr
If all you are doing is adding css to the page, then I would suggest you use the Stylish addon, and write a user style instead of a user script, because a user style is more efficient and appropriate.
See this page with information on how to create a user style