<!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>為什么事件在函數里調用必須等于函數?在函數里調用值沒有執行事件操作 為什么事件還是會自動執行?
誰能解釋下下面這段代碼的錯誤
清風流光
2017-04-16 05:27:42