TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

JavaScript: Difference Between GetElementByID and QuerySelector

4 点作者 kiru_io超过 1 年前

1 comment

6510超过 1 年前
Interesting difference but why is querySelector(`#${CSS.escape(id)}`) better?<p>I would prefer to use valid id&#x27;s but also, when selecting by id I just use getElementByID?<p>You could also use querySelectorAll(id) and have more than one element with the same id. It doesn&#x27;t seem like a good idea.
评论 #39013191 未加载