/**
* @description event binding, compatible with all browsers
* @param target event trigger object
* @param type event
* @param func event processing function
*/
function addEvents(target , type, func) {
if (target.addEventListener) //Not ie and ie9
target.addEventListener(type, func, false);
else if (target.attachEvent) //ie6 to ie8
target.attachEvent("on" type, func);
else target["on" type] = func; //ie5
};
/**
* @description event removal, compatible with all browsers
* @param target event trigger object
* @param type event
* @param func event handler function
*/
function removeEvents(target, type, func ){
if (target.removeEventListener)
target.removeEventListener(type, func, false);
else if (target.detachEvent)
target.detachEvent("on" type, func);
else target["on" type] = null;
};
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn