<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text" id="fInp"/>
<script>
var eventRegister = function(dom, type, data, callBack){
var callback = function(e){
callBack(e,data);
}
if(window.addEventListener){
dom.addEventListener(type, callback, false);
}else if(window.attachEvent){
dom.attachEvent(‘on‘+type, callback);
}
};
function handler(e,data){
console.log(e);
console.log(data);
}
eventRegister(document.getElementById(‘fInp‘), ‘click‘, {name:‘kk‘}, handler);
</script>
</body>
</html>
时间: 2024-10-11 21:05:51