Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
class not added using jquery addClass, trumped by class in CSS
Old 09-23-2009, 02:47 AM class not added using jquery addClass, trumped by class in CSS
seannarae's Avatar
Skilled Talker

Posts: 65
Location: san francisco, ca
Trades: 0
Please see my TEST PAGE
(which contains a deliberately truncated example of whats going on in my main working page)

I am having trouble getting the class added via addClass to trump the CSS already on that element
I have LI's styled via CSS, each with their own unique class.
Using jquery addClass, i'd like to swap those classes with a different class (mouseover)
But the only properties added are those not specifically called in the default class
For example, the text-decoration is the only thing added because thats the only part of the addClass class not trumped.
As a test, i strike the BG-color from one of the default classes, and it works: the BG-color from the addClass class displays.

I have tried moving the addClass class higher-up in the CSS stack, thinking sequence would make a difference, but no joy.

Any assistance is appreciated...
seannarae is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-23-2009, 11:02 AM Re: class not added using jquery addClass, trumped by class in CSS
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
This has nothing to do with JavaScript. It is just because of the specificity of the CSS cascade. More specific rules will always take precedence. Sometimes when I have a class that gets added that is meant to trump other rules regardless, I will place the !important tag after the rule in the code block:

CSS
Code:
.hover {
    text-decoration:underline;
    color:#FF6600 !important;
    background-color:#CCCC00 !important;
}
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 09-23-2009, 02:04 PM RESOLVED Re: class not added using jquery addClass, trumped by class in CSS
seannarae's Avatar
Skilled Talker

Posts: 65
Location: san francisco, ca
Trades: 0
Thanks for the response. I was on the fence whether this was a CSS issue or a jQuery syntax issue.

Your suggestion worked perfectly. I'd seen the !important declaration before, but never had a practical chance to use/see it in action.

thanks again...
seannarae
seannarae is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to class not added using jquery addClass, trumped by class in CSS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.87795 seconds with 12 queries