第一種
<p id='oo'>ddddddddddddddddddddddddddddddd</p>
<script>
var x=document.getElementById("oo");
x.onclick=function(e){
alert(e.type)
}
</script>
第二種
<p id='oo' onclick=getType(event)>ddddddddddddddddddddddddddddddd</p>
<script>
function getType(e){
alert(e.type);
alert(e.clientX);
}
</script>
第三種
<p id='oo')>ddddddddddddddddddddddddddddddd</p>
<script>
var x=document.getElementById("oo");
x.addEventListener("click", function(e) {
alert(e.type);
});
</script>
也可以是
<p id='oo')>ddddddddddddddddddddddddddddddd</p>
<script>
var x=document.getElementById("oo");
x.addEventListener("click",function(){
getType(event)
})
function getType(e){
alert(e.type);
}
</script>
實際上是綁定事件的多種方式~