I have been searching but have come up blank and i\'m wondering if I can use one jQuery statement to target multiple elements on a page. I have several identical buttons on a pa
You can do:
$(".learnMoreButton, .bioButton").hover(function() {
$(this).find(".buttonRight")...
...
}, function() {
...
});
I will add that I think you'd be better off doing that with CSS classes.
.buttonLeft { background: url(/images/concaveBtn-Left.gif) }
.buttonMiddle { background-image: url(/images/concaveBtn-Middle.gif) }
.buttonMiddle a { color: #666; }
.buttonRight { url(/images/concaveBtn-Right.gif) }
.hoverover .buttonLeft { url(/images/concaveBtn-Left2.gif) }
.hoverover .buttonMiddle { url(/images/concaveBtn-Middle2.gif) }
.hoverover .buttonMiddle a { color: #FFF; }
.hoverover .buttonRight { background: url(/images/concaveBtn-Right2.gif) }
and
$(".learnMoreButton, .bioButton").hover(function() {
$(this).addClass("hoverover");
}, function() {
$(this).removeClass("hoverover");
});
and you'll have a lot less code.
Also you can give elements multiple classes so:
and then it becomes even simpler:
$(".hoverbutton").hover(function() {
$(this).addClass("hoverover");
}, function() {
$(this).removeClass("hoverover");
});