change background color of li using jquery

前端 未结 4 1362
情书的邮戳
情书的邮戳 2021-01-22 23:56

I want to change the color of li which contains anchor when the mouse go over it, I make like this

 
4条回答
  •  青春惊慌失措
    2021-01-23 00:40

    Id is unique so dont repeat, u can use in class

    $(document).ready(function(){
      $(".son").hover(function(){
        $(".sonItem").css("background-color","black");
        },function(){
        $(".sonItem").css("background-color","white");
        });
    });
    
    
    

提交回复
热议问题