日期:2014-05-16 浏览次数:20520 次
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
div {
width:100px; height:100px;
background:#eee;
}
</style>
</head>
<body>
<div id="test"></div>
<script>
$('#test').mouseover(function(){
$(this).css('backgroundColor', 'red');
}).mouseout(function(){
$(this).css('backgroundColor', '#eee');
})
</script>
</body>
</html>
------解决方案--------------------
有现成的模拟hover伪类,何必费那个劲还加onmouseover和onmouseout?
<html>
<head>
<title>Jquery Hover</title>
</head>
<script src="http://code.jquery.com/jquery.js"></script>
<script>
$(function (){
$("button").hover(
function(){
alert("do onMouseover");
},
function(){
alert("do onMouseout");
}
);
})
</script>
<body>
<button>Button</button>
</body>
</html>
------解决方案--------------------
上面已有答案了。