<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
ul{
padding: 0;
margin: 0;
}
li{
list-style-type: none;
float: left;
padding: 5px 7px;
margin-right: 10px;
}
.check{
background: yellow;
}
</style>
</head>
<body>
<ul>
<li class="check">qweqe</li>
<li>asdasd</li>
<li>zxczxc</li>
<li>try</li>
</ul>
<script type="text/javascript">
var liArr=document.getElementsByTagName("li");
for (var i=0;i<liArr.length;i++) {
var obj=liArr[i];
obj.οnclick=function(){
for (var j=0;j<liArr.length;j++) {
var obj2=liArr[j];
obj2.className="";
}
this.className="check";
}
}
</script>
</body>
</html>
JavaScript 选项卡
最新推荐文章于 2022-09-24 20:27:32 发布