您的位置:首页 > Web前端 > JavaScript

根据事件类型做出反应

2017-06-02 23:19 239 查看
window.onload=function(){
var box=document.getElementById("box");
function thingstype(ev){
var e=ev||event;
switch(e.type){
case'click':e.target.style.background='blue';break;
case'mouseenter':e.target.style.background='green';break;
case'mouseleave':e.target.style.background='yellow';break;
}
}
box.onclick=function(){
thingstype();
}
}


好像这么玩 用处不大...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  封装 js 事件