<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
<script>
$(function(){
$('#btn').click(function(){
$('.box').toggleClass('col01');
})
})
</script>
</head>
<style type="text/css">
.box{
width:200px;
height:200px;
background: gold;
}
.col01{
background-color:green;
}
</style>
<body>
<input type="button" name='' value=' 切换样式' id='btn'>
<div class='box'>div元素<
绑定click事件、获取元素索引值
最新推荐文章于 2021-08-30 14:21:11 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)