时间:2021-07-01 10:21:17 帮助过:53人阅读
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>hover demo</title>
<style>
ul {
margin-left: 20px;
color: blue;
}
li {
cursor: default;
}
span {
color: red;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<ul>
<li>Milk</li>
<li>Bread</li>
<li class="fade">Chips</li>
<li class="fade">Socks</li>
</ul>
<script>
$( "li" ).hover(//为li绑定了鼠标进入和鼠标移开的两个参数
function() {
$( this ).append( $( "<span> ***</span>" ) );
}, function() {
$( this ).find( "span:last" ).remove();
}
);
$( "li.fade" ).hover(function() {<pre name="code" class="html" style="color: rgb(51, 51, 51);
font-size: 14px; line-height: 26px;">//为li元素下的class类是fade的所有元素绑定了鼠标进入参数
$( this ).fadeOut( 100 );
$( this ).fadeIn( 500 );});
</script>
</body>
</html>以上就是关于jQuery鼠标悬停事件.hover()的使用详解的详细内容,更多请关注Gxl网其它相关文章!