【发布时间】:2021-09-09 14:09:44
【问题描述】:
我想立即从特定 CSS 选择器中检索值列表。
我只想提取<strong> 中的文本。我正在使用:
document.querySelectorAll("p > strong")
但是我有一个节点列表...
NodeList(101) [strong, strong, strong, strong, strong, strong, strong, strong, strong,...]
我的目标是 innerText 像:
document.querySelectorAll("p > strong")[1].innerText
如何一次提取列表中的所有目标文本值?
【问题讨论】:
-
标记为jquery 所以:
$("p>strong").map((i,e) => $(e).text()).toArray()(不作为答案提供,因为它看起来不像你实际上想要jquery。
标签: javascript jquery css nodelist