一:简单变换
// An highlighted block
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div></div>
<script>
var div = document.getElementsByTagName('div')[0];
div.style.width = "100px";
div.style.height = "100px";
div.style.backgroundColor = "red";
var count = 0;
div.onclick = function () {
count++;
if (count % 2 == 1) {
this.style.backgroundColor = "purple";
this.style.borderRadius = "50%";
div.style.width = "200px";
div.style.height = "200px";
} else {
div.style.width = "100px";
div.style.height = "100px";
div.style.backgroundColor = "red";
}
}
</script>
</body>
</html>