Saturday, November 28, 2009

Re: [jQuery] Change a css value for a child of the selected element

Hi,
 
It's nearly what I'm searching for :)
 
The problem with your function, is that the script change ALL the <a> for the child. I just wanna change the first one :)
 
Thanx a lot
----- Original Message -----
Sent: Saturday, November 28, 2009 6:34 PM
Subject: Re: [jQuery] Change a css value for a child of the selected element

$(function() {
var list_item = $("li");
var current = -1;
list_item.hover(function() {
var index = list_item.index($(this));
if(index != current) {
$("a", list_item.eq(index)).css({backgroundColor:'#ccc'});
index = current;
}
}, function() {
$("a", list_item.eq(current).css({ backgroundColor:"#FFF"});
});

});

No comments: