设计场景
- 给元素绑定事件
问题
- 兼容性问题
解决方案
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);
}
};