Show items with display style: none! important (jQuery)

As said in jQuery Documentation ---. Show ()

Note. If you use ! important in their styles, for example display: none! important , you must override the style using .css ('display', 'block! important') if you want to use .show () to function correctly.

But it looks like the style cannot be overridden, and the element cannot be displayed. Am I something wrong here?

jsfiddle

+4
source share
3 answers

When you use attr , it may work. jQueries .css() and .prop() both not work

In this attr script, remove !important from javascript and you will see how CSS !important overlaps even the inline style.

your violin

+5
source

Alternatively, you can do this using classes (so that all of your CSS is in the CSS files themselves and will not be directly modified by javascript): http://jsfiddle.net/FF3mc/4/

+3
source
 $('.classname').attr("style", "display: block !important"); 

We cannot use .css () here because it does not support! important.

+1
source

Source: https://habr.com/ru/post/1440028/


All Articles