只是问题:有什么方法可以完全删除对象的所有事件,例如 div?
编辑:我正在添加每个div.addEventListener('click',eventReturner(),false);
事件。
function eventReturner() {
return function() {
dosomething();
};
}
EDIT2:我找到了一种有效的方法,但不能用于我的情况:
var returnedFunction;
function addit() {
var div = document.getElementById('div');
returnedFunction = eventReturner();
div.addEventListener('click',returnedFunction,false); //You HAVE to take here a var and not the direct call to eventReturner(), because the function address must be the same, and it would change, if the function was called again.
}
function removeit() {
var div = document.getElementById('div');
div.removeEventListener('click',returnedFunction,false);
}