getElementById 测验
单选题 简单
题目
什么做 `document.getElementById('主要')` 返回如果否 元素有 id='主要'?
提示
getElementById 返回空 当否 match 是找到.
解释
getElementById returns the element with the matching id, or null if no element has that id. It does not throw an error or return undefined. This is why you should always check the result before using it: const el = document.getElementById('main'); if (el) { ... }.
相关资源
相关课程
- DOM
学习关于 getElementById.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。