color of the
  • change in on mouse over and click event using jquery
  • 后端 未结 3 1140
    轮回少年
    轮回少年 2020-12-10 23:45

    I want to change the color of the li as red on mouse over. And keep the same color in click event also. I have the following list,

    
      
    
            
    3条回答
    •  旧巷少年郎
      2020-12-10 23:52

      Use css for that:

      li:hover {
          color:red;
      }
      

      And this is not recommended:

      li:focus {
          color: red;
      }
      

      JQuery

      $('li').click(function(){
          $(this).css('color','red');
      });
      

    提交回复
    热议问题