[06--DOM] toggle操作
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#a1{
height: 400px;
width:400px;
}
.red{
background-color: red;
}
.green{
background-color: green;
}
</style>
</head>
<body>
<div id="a1" class="red green"></div>
<script>
var a = document.getElementById("a1");
a.classList.toggle(green)
</script>
</body>
</html>