问个问题: 有没有办法完全删除对象的所有事件,比如 div?
编辑: 我在每个 div.addEventListener('click',eventReturner(),false);
添加一个事件。
function eventReturner() {
return function() {
dosomething();
};
}
编辑2: 我找到了一种方法,这种方法很有效,但不能用于我的案子:
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);
}