Reputation: 123
I'm trying something like this
jQuery(document).ready(function($){
$('nav ul li').hover(
function() {
$('this.menu1bar').animate({ backgroundColor: "#95c938" }, "fast");
$('this.menu2bar').animate({ backgroundColor: "#95c938" }, "fast");
},
function() {
$('this.menu1bar').animate({ backgroundColor: "#a99672" }, "fast");
$('this.menu2bar').animate({ backgroundColor: "#a99672" }, "fast");
}
);
});
The objective of this code is animate the children div .menu1bar and .menu2bar can anyone help with this step, the code works for all children divs of UL, but im only want the children of LI hover event.
Upvotes: 2
Views: 6225
Reputation: 1222
Try using children() to select a specific element. Something like this:
$('this').children('.menu1bar').animate({ backgroundColor: "#95c938" }, "fast");
Edit:
Of course you can also use find(), but there's a difference:
Upvotes: 2
Reputation: 13230
Please show your HTML Markup. I think that the problem might be in the following...
$('this.menu1bar')
try
$(this).find('.menu1bar')
Upvotes: 0
Reputation: 5403
This should work:
jQuery(document).ready(function($){
$('#nav ul li').hover(
function() {
$(this).find('.menu1bar,.menu2bar').animate({ backgroundColor: "#95c938" }, "fast");
},
function() {
$(this).find('.menu1bar,.menu2bar').animate({ backgroundColor: "#a99672" }, "fast");
}
);
});
Upvotes: 2