这篇文章主要介绍了关于jquery的增减类的操作(附代码),有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{padding: 0;margin: 0;}
ul{
list-style: none;
}
ul li{
width: 100px;
height: 40px;
line-height: 40px;
text-align: center;
background: #87CEEB;
float: left;
}
ul li.active{
background: #00FF00;
}
</style>
<script src="js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<ul>
<li>list1</li>
<li>list2</li>
<li>list3</li>
<li>list4</li>
</ul>
</body>
<script type="text/javascript">
//用mouseover方法
$("ul li").mouseover(function(){
$(this).addClass("active");
}).mouseout(function(){
$(this).removeClass("active");
})
//结合选择器选择
$("ul li").mouseover(function(){
$(this).addClass("active").siblings("li").removeClass("active");
})
</script>
</html>相关推荐:
以上就是关于jQuery的增减类的操作(附代码)的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号