我正在尝试简单地检查我是否有一个空的输入文本框,但是当我在chrome中运行这个错误时会得到这个错误:
Uncaught TypeError: Cannot read property 'length' of undefined.
function walkmydog() { //when the user starts entering if(document.getElementById('WallSearch').value.length == 0) { alert("nothing"); } } if (document.addEventListener) { document.addEventListener("DOMContentLoaded",walkmydog,false); }