我的onblur
事件正在触发window.onload
。我怀疑我选择错误的节点。当我console.log(input)
在function checkList()
它显示<input name='newTask'>
这是正确的使用方法onblur
吗?
app.view = (function(){
function init(){
checkList();
}
function checkList(){
var input = document.getElementsByName('newTask')[0];
input.onblur = checkInput();
requestAnimFrame(checkList);
}
function checkInput(){
alert('check input');
}
return {
init : init
}
})();
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
window.onload = function(){
app.view.init();
}