<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.red {
width: 100px;
height: 100px;
background: red;
}
.blue {
width: 100px;
height: 100px;
background: blue;
}
</style>
<script>
window.onload = function() {
var box = document.getElementById('box');
box.onclick = toBlue();
}
function toRed() {
this.className = 'red'
this.onclick = toBlue()
}
function toBlue() {
this.className = 'blue'
this.onclick = toRed()
}
</script>
</head>
<body>
<div id='box' class="red" style="text-align: center;line-height: 100px;">DIV</div>
<body/>
</html>为什么事件在函数里调用必须等于函数
在函数里调用值没有执行事件操作 为什么事件还是会自动执行?
清风流光
ruibin
西兰花伟大炮
落叶1111
slumdog
慕的地6079101
随时随地看视频慕课网APP
相关分类