jquery help
- Started
- Last post
- 8 Responses
- Stugoo
guys,
im using jquery to fade some colours on rollover, i am using class="active" on the <a> to determine the active page.
however when I run my function the fade is applying to the active state too...im trying to use filter to exclude it but am not sure the best way to go about it... any ideas?
here is my function :
$( function() {//Grab the original BG color of the link
var original_bg = $("#primary li a").css("background-color");
var original_text = $("#primary li a").css("color");
var active_bg = $("#primary li a.active").css("background-color...
var active_text = $("#primary li a.active").css("color");$("#primary li a").filter(".active").hover(
function() {
$(this)
.css({backgroundColor:original_b...
.animate({backgroundColor:active... 400)
},
function(){
$(this)
.animate({backgroundColor:origin... 400)
});
});
cheers
- neverblink0
I'm not entirly sure what you're trying to do.. but something like this?
$(a ^.active).hover( function(){
$this.animate({
backgroundColor: "#F09",
color: "#FFF"
}, 500);
});(not tested)
- use ^ to excludeneverblink
- illl have a test and get back to you.... never knew about ^Stugoo
- ahh.. got things mixed up..
use .not(subselector)neverblink - i'm no progger but maybe $('a.active').hover...
//do magic
})
?
since a.active is already filtering the active from the non active?caoimh - ooops...thats not right...hows about - $('a').not([a.active...caoimh
- 3030
Stugoo, do you get any errors? What FireBug says?
- Stugoo0
Im not erroring.
im trying to exclude the active state with the hover..
here is my html :
<ul id="primary">
<li><a class="active" href="" title="Home" >Home</a></li>
<li><a href="audiences/" title="Audiences">Audiences</a></li>
<li><a href="consumer-insight/" title="Consumer Insight">Consumer Insight</a></li>
<li><a href="magazines-ad-planning/" title="Magazine Ad Planning">Magazine Ad Planning</a></li>
<li><a href="case-studies/" title="Case Studies">Case Studies</a></li>
<li><a href="news/" title="News">News</a>
<ul>
<li><a href="news/archive.cfm" title="News Archive">News Archive</a></li>
<li><a href="news/polls/" title="Polls">Polls</a></li>
</ul>
</li>
<li><a href="contact/" title="Contact">Contact</a></li>
</ul>
- Stugoo0
thanks caoimh
$("#primary li a").not("a.active").hover(
//magicworks a treat.
_very_ much appreciated!
- doctor0
Can you show an example?
- ptouch7180
ive tackled this in the past but came up with a different solution.
- Stugoo0
yeah sure, ill post later, up to my eyeballs.
- Stugoo0
Sorry it took so long to get this up.
Final 2 level side nav
http://www.stugoo.co.uk/testbed/…