菩提子3833937
2016-12-28 15:47
function addEvent(ele,type,handler){
// 执行代码
if(ele.addEventLister){
ele.addEventLister(type,handler,false);
}else if(ele.attachEvent){
ele.attachEvent('on'+type,handler);
}else{
ele['on'+type]=handler;
}
};
//阻止冒泡
function stopPropagation(ev){
var oEvent=ev || event;
if(oEvent.stopPropagation){
oEvent.stopPropagation();
}else{
oEvent.cancelBubble=true;
}
}
// 显示登录层函数
function showLogin(){
login_box.style.display='block';
}
// 隐藏登录层函数
function hideLogin(ev){
var oEvent = ev || event;
login_box.style.display='none';
oEvent.stopProgation();
}
//点击登录按钮显示登录层
addEvent(login_btn,'click',showLogin);
//点击关闭按钮隐藏登录层
addEvent(close,'click',hideLogin);
oEvent.stopProgation();这里拼写错了,应该是oEvent.stopPropagation();
DOM事件探秘
99544 学习 · 1197 问题
相似问题