gpt4 book ai didi

node.js - 使用 cheerio 选择具有属性的元素

转载 作者:搜寻专家 更新时间:2023-10-31 22:28:01 26 4
gpt4 key购买 nike

选择具有特定属性的所有 dom 元素的最有效方法是什么。

<input name="mode">

对于纯 javascript,我会使用:document.querySelectorAll("[name='mode']")document.querySelectorAll([name]") 如果我不关心属性值。

最佳答案

好的,我在 cheerio 文档中找到了它,这是您的操作方法:

$('[name=mode]')

cheerio docs: Selectors

关于node.js - 使用 cheerio 选择具有属性的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41193800/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com