在JQuery中提供了hover事件,以简化Dom中的mouseenter,和mouseleave事件,hover的第一个参数(匿名方法)表示mouseenter,第二个参数表示mouseleave,即表示可以为hover传递两个参数。如下代码所示:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
.in {
background-color:blue;
color:white;
border-style:solid;
}

</style>
<script src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
$("#btn").hover(function () {
$(this).addClass("in");
}, //mouseenter
function () {
$(this).removeClass("in");
});//mouseleave
});
</script>
</head>
<body>
<button id="btn">click me</button>
</body>
</html>