第 14 课 7 / 18 | 编码:L14-11
核心知识

querySelectorAll 与 NodeList

querySelectorAll 返回所有匹配元素组成的静态 NodeList,可能为空集合。

  • 使用 length 查看数量
  • 可用 for...of 遍历
  • 集合不是单个元素,不能直接改 textContent
const cards = document.querySelectorAll('.card');
for (const card of cards) card.classList.add('ready');