jQuery hover and class selector

后端 未结 10 1770
半阙折子戏
半阙折子戏 2020-12-10 00:56

I wan\'t to change the background color of a div dynamicly using the following HTML, CSS and javascript. HTML:


      
      
10条回答
  •  青春惊慌失措
    2020-12-10 01:24

    On a side note this is more efficient:

    $(".menuItem").hover(function(){
        this.style.backgroundColor = "#F00";
    }, function() {
        this.style.backgroundColor = "#000";
    });
    

提交回复
热议问题