jQuery之开关灯示例

准备jquery-3.2.1.js文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.c11 {
height: 100px;
width: 100px;
border-radius: 50%;
border: 1px solid #cccccc;
display: inline-block;
} .c12 {
background-color: yellow;
}
</style>
</head>
<body> <div class="c11"></div>
<button id="switch" class="btn btn-default">开关</button>
<script src="jquery-3.2.1.js"></script>
<script>
// id选择器
// $("#i1") // $("#switch")[0].onclick = function () {
// ....
// }
//jQuery绑定事件
$("#switch").on("click", function () {
// 找灯泡
$(".c11").toggleClass("c12");
}) </script>
</body>
</html>
上一篇:innodb_stats_on_metadata and slow queries on INFORMATION_SCHEMA


下一篇:Repeater 实现 OnSelectedIndexChanged