Highlight div box on hover

后端 未结 4 2069
暖寄归人
暖寄归人 2021-02-08 10:29

Say I have a div with the following attributes:

.box {
  width: 300px;
  height: 67px;
  margin-bottom: 15px;
}

How would I make it so that if

4条回答
  •  被撕碎了的回忆
    2021-02-08 10:57

    You can do it with CSS only:

    .box:hover{
      background: blue;
      cursor: pointer;
    }
    

    Or with Javascript (I'm using jQuery in this example)

    ;(function($){
      $('.box').bind('hover', function(e) {
        $(this).css('background', 'blue');
      });
    })(jQuery);
    

提交回复
热议问题