<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script src="js/jquery-1.11.2.min.js"></script> <style type="text/css"> .d{ height: 150px; width: 150px; margin: 5px; background-color: red; float: left; } </style> </head> <body> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> <div class="d"></div> </body> <script> $(".d").mouseover(function(){ //让所有的div变成红色 $(".d").css("background","red") //让选中的变成绿色 $(this).css("background","green") }) $(".d").mouseleave(function(){ $(".d").css("background-color","red") }) </script> </html>