I searched, but came up with an empty one, and I wonder if I can use a single jQuery statement to specify multiple elements on a page. I have several identical buttons on the page, and each of them consists of a left, middle and right background, where the middle contains text and can expand to any desired size. Each of them has a unique identifier and / or class. I have a setting now, so when you hover over your container div, the 3 backgrounds change to make it appear that the buttons are in a different state. The way this is done now is 1 hover call for each button that is in the class (most likely it will use an ID, but you cannot have multiple elements with the same ID). This course is followed by 8 events. Change the background for each right left and middle colors and change the color for text in the middle.
This means a lot of lines of code. I want to be able to call all buttons with a hover event at the same time or have a hover event, somehow know which button is hovering and throw this class or identifier or even a name back into jQuery, which can then change the subclasses of the buttons for left and right average. The subclass for the right and middle levels is identical for all buttons, therefore, if the hover event can be focused on any event called by it, I need only one set of calls to change the background attributes ... The current code is below for two buttons ...
$j(".learnMoreButton").hover( function () { $j('.learnMoreButton .buttonLeft').css({background:"url(/images/concaveBtn-Left2.gif)"}); $j('.learnMoreButton .buttonMiddle').css("background-image", "url(/images/concaveBtn-Middle2.gif)"); $j('.learnMoreButton .buttonMiddle a').css({color:"#ffffff"}); $j('.learnMoreButton .buttonRight').css({background:"url(/images/concaveBtn-Right2.gif)"}); }, function () { $j('.learnMoreButton .buttonLeft').css({background:"url(/images/concaveBtn-Left.gif)"}); $j('.learnMoreButton .buttonMiddle').css("background-image", "url(/images/concaveBtn-Middle.gif)"); $j('.learnMoreButton .buttonMiddle a').css("color", "#666"); $j('.learnMoreButton .buttonRight').css({background:"url(/images/concaveBtn-Right.gif)"}); } ); $j(".bioButton").hover( function () { $j('.bioButton .buttonLeft').css({background:"url(/images/concaveBtn-Left2.gif)"}); $j('.bioButton .buttonMiddle').css("background-image", "url(/images/concaveBtn-Middle2.gif)"); $j('.bioButton .buttonMiddle a').css({color:"#ffffff"}); $j('.bioButton .buttonRight').css({background:"url(/images/concaveBtn-Right2.gif)"}); }, function () { $j('.bioButton .buttonLeft').css({background:"url(/images/concaveBtn-Left.gif)"}); $j('.bioButton .buttonMiddle').css("background-image", "url(/images/concaveBtn-Middle.gif)"); $j('.bioButton .buttonMiddle a').css("color", "#666"); $j('.bioButton .buttonRight').css({background:"url(/images/concaveBtn-Right.gif)"}); } );
jquery css
Rac
source share