Targeting multiple elements with jQuery

后端 未结 5 2043
无人及你
无人及你 2021-02-06 04:34

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

5条回答
  •  孤独总比滥情好
    2021-02-06 05:07

    Currently the code looks like this:

    $j(function (){  
        $j(".hoverBTN").hover( 
        function() {
            $j(this).addClass("hoveroverL");
            $j(this).addClass("hoveroverM");
            $j(this).addClass("hoveroverR");
        }, function() {
            $j(this).removeClass("hoveroverL");
            $j(this).removeClass("hoveroverM");
            $j(this).removeClass("hoveroverR");
        });
    
    });   
    

    Which works but on the wrong elements. It currently changes the button being hovered over but it adds 3 classes to the buttons wrapper not to the sub classes for Right Left And Middle: An example of the button is:

    Timeline

提交回复
热议问题