Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show elements with style display:none !important (jQuery)

Tags:

jquery

css

show

As said in jQuery documentation --- .show()

Note: If using !important in your styles, such as display: none !important, it is necessary to override the style using .css('display', 'block !important') should you wish for .show() to function correctly.

But it seems the style cannot be overridden and the element cannot be shown. Am I doing anything wrong here?

jsfiddle

like image 634
user1643156 Avatar asked Dec 27 '22 16:12

user1643156


2 Answers

When you use the attr it can work. jQueries .css() and .prop() both won't work

In this fiddle with attr remove the !important from the javascript and you will see how the CSS !important overrules even the inline styling.

your fiddle

like image 167
bart s Avatar answered Jan 22 '23 23:01

bart s


Alternatively you can do it with classes (so all your CSS is in the CSS files themselves, and not being directly altered by javascript): http://jsfiddle.net/FF3mc/4/

like image 45
manavo Avatar answered Jan 22 '23 23:01

manavo