Bug Tracker


Ticket #2066 (closed bug: invalid)

Opened 6 years ago

Last modified 2 years ago

.css({height: "300px !important"})

Reported by: rortelli Owned by:
Priority: minor Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocking: Blocked by:


The !important declaration works only on FF 2.x IE6 & IE7 broke Safari 2.x doesn't brokes but it'll not apply the css rule

Same problem using .css("height", "300px !important");

Change History

comment:1 Changed 6 years ago by davidserduke

  • Status changed from new to closed
  • Resolution set to invalid

Only Safari 3 Win of the browsers I tested lets you do that. The other browsers either ignore the !important keyword or throw an error (IE). Even if you do

document.getElementById("tester").style.height = "300px !important";

it fails in all browsers except Safari so this isn't a jQuery bug. There is, however, a work around. You can set it directly on the cssText.

$("#tester").css("cssText", "height: 300px !important;");

And this seems to work. Of course you have to be careful setting cssText since it sets/clears everything in the css for that element.

Hope that helps.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.