Css stylesheet stronger than jquery addClass?

According to css priorities, if your class . Brown is defined like this in your css file.

According to css priorities, if your class . Brown is defined like this in your css file : . Brown{} The rules inside will not override same rules in your # selector.

You can make it override them using the! Important keyword. .

Brown { color: brown! Important; } Altough this is not the best solution here, it will work... The less you use! Important, the more your code will be easy to read.

See stuffandnonsense.co.uk/archives/css_spec....

That helped me! Thanks! – Nima Jul 30 at 22:14.

Do you have a . Brown selector in your CSS? Also an a tag might be a bad choice because it has a very good :hover selector build in.

Yep, but if I take the normal hover action it doesn't work well. I want to make a menu with hover and active effect, but I want to style it with jquery. – user134282 Sep 18 '09 at 11:59 .

Css({"color","red"}); does work – user134282 Sep 18 '09 at 12:00 Why would you want to style it with jQuery? Is there something different than adding it using CSS? – exhuma Sep 18 '09 at 12:01.

I don't see you mention a issue with using css to do this, so why not try: ul#menuCnt li a:hover { color:"brown"; } Edit: It should actually work in ie6, seeing as it is an anchor :) It would be much faster than using javascript to do it.

You have a very specific element specifier here. That's considered more important than a simple . Brown class selector, and thus it doesn't have much effect.

See for example this site for more info.

For example: #menuCnt li a { color: "red"; } #menuCnt li a:hover { color: "brown"; } Also, the usage of "UL" in the selector shouldn't be necessary. There's no way that there are other elements on the page with the ID "menuCnt" as the ID attribute must be unique in the DOM.

I did some testing with IE/FF and discovered that including the element's ID in your stylesheet (ul#menuCnt) prevents JQuery from overriding that style - at least with the methods I employed (toggleClass, addClass, removeClass, etc. ). If you assign the class to the element in the tag (instead of specifying the ID in the stylesheet) you can override it with JQuery. If you remove the ID from the style you can override it with JQuery (not really useful but good for demonstrating behavior).

In fact, if you leave the ID in your stylesheet and attempt to assign a different class within the tag, you still see the class associated with the ID in the stylesheet. NOTE: Vincent's post suggests why we see this behavior. I also agree with exhuma's suggestion to use :hover in your CSS.

Thanks for your help. So you think that I should make the hover effect with a:hover. Okay, that works so far :) ANd wat should I do with the active state?

Jquery or with a:active? – user134282 Sep 20 '09 at 17:37 I've always relied on CSS to style the various states of links (visited, hover, etc. ). – Mayo Sep 20 '09 at 22:21.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions