javascript - 使用 document.querySelector('#id') 和 document.getElementById('id') 的区别
问题描述
我是 javascript 的初学者,我看到很多人使用document.querySelector('#id')
和一些人使用document.getElementById('id')
id 来获取 html 元素。请回答天气这些是相同的,否则我们必须以不同的方式使用它们。
解决方案
推荐阅读
- jenkins - 当 CPU 使用率高时,Jenkins 使 Kubernetes 节点卡住
- computer-vision - “R-CNN 变体中使用的 BB 回归算法”与“YOLO 中的 BB”定位技术有什么区别?
- mysql - 每周每天每小时的登录次数?
- java - 如何将 cookie 添加到 Undertow 的 ClientRequest?
- bash - 使用 bash 脚本删除特定的行集
- python - 如何将 DataFrame 列的非空条目组合成新列?
- javascript - 使用 intro.js 时几乎看不到 D3 工具提示
- celery - 如何向用户显示预定的 cron - Celery 调度程序?
- flutter - 如何从推送通知导航到 BottomNavigationBar 上的特定选项卡?
- javascript - 如何使用css在顶部导航栏上添加后退按钮?