console
function alertSecond(){
alert("第二次");
}
function changeColor(){
if(this.style.color=="red"){
this.style.color="black";
}
else{
this.style.color="red";
}
}
function changeBack(){
if(this.style.color=="red"){
this.style.color="black";
}
else{
this.style.color="red";
}
}
window.onload = function ()
{
var oBtn = document.getElementById("btn");
oBtn.onclick = function () {
alert("第1次");
};
oBtn.onclick = function () {
alert("第2次");
};
oBtn.onclick = function () {
alert("第1次");
alert("第2次");
alert("第3次");
};
var oBtn=document.getElementById("listenBen");
oBtn.addEventListener("click",function(){
alert("第1次");
},false);
oBtn.addEventListener("click",alertSecond,false);
oBtn.removeEventListener("click",alertSecond,false);
var oPContent=document.getElementById("removeBtn");
oPContent.addEventListener("click",changeColor,falese);
oPContent.addEventListener("click",change,falese);
oBtn.addEventListener("click",function(){
oPContent.removeEventListener("click",changeColor,false);
},false);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
</script>
</head>
<body>
<input id="btn" type="button" value="按钮"/>
<br/>
<br/>
<input id="listenBtn" type="button" value="监听按钮"/>
<div>
<p id="content">广州新华学院</p>
<button id="removeBtn">解除</button>
<div>
<p id="content">信息科学学院</p>
<button id="removeBtn">解除</button>
</div>
</div>
</body>
</html>