Change background color on mouseover and remove it after mouseout

前端 未结 7 1105
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 10:38

I have table which class is forum. My jquery code:



        
相关标签:
7条回答
  • 2020-12-05 11:04

    This is my solution :

    $(document).ready(function () {
      $( "td" ).on({
        "click": clicked,
        "mouseover": hovered,
        "mouseout": mouseout
    });
    
    var flag=0;
    
    function hovered(){
      $(this).css("background", "#380606");
    }
    
    function mouseout(){
      if (flag == 0){
      $(this).css("background", "#ffffff");
    } else {
      flag=0;
    }
    }
    
    function clicked(){
      $(this).css("background","#000000");
      flag=1;
    }
    })
    
    0 讨论(0)
提交回复
热议问题