设计场景
- 给元素绑定事件
问题
- 兼容性问题
解决方案
function bindEvent(domObj, eventType, handler)
{
if(domObj.attachEvent)
{
domObj.attachEvent('on'+eventType, handler);
}
else
{
domObj.addEventListener(eventType, hander, false);
}
};
function bindEvent(domObj, eventType, handler)
{
if(domObj.attachEvent)
{
domObj.attachEvent('on'+eventType, handler);
}
else
{
domObj.addEventListener(eventType, hander, false);
}
};
本文标题:javascript之“事件绑定”
本文链接:https://www.haomeiwen.com/subject/deondttx.html
网友评论