如果 ID 不存在,则脚本会中断。为什么?
如何查看 the_lis?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>test</title>
</head>
<body>
<script>
window.onload = function(){
alert('this will alert');
var the_id = document.getElementById('a_id_that_does_not_exist'),
the_lis = the_id.getElementsByTagName('li');
alert('this will NOT alert');
}
</script>
</body>
</html>