如何使用queryselector选择位于属性内的属性? [英] How to select the attribute that inside an attribute using queryselector?
本文介绍了如何使用queryselector选择位于属性内的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想学习如何选择包含组一词的 href
。 href
在 role = present
中之下或之内。请更正我的代码
I want to learn how to select the href
that contains the word 'groups'. That href
is under or inside in role="present"
. Please correct my code
document.querySelectorAll("[role=article[href*="groups"]]")[1].innerHTML;
推荐答案
反引号`;允许$ {}访问变量...另一种方法是将字符串连接在一起。
backtick "`" allows for ${} access to variables... the other way is to concat strings together.
document.querySelectorAll(`[role=article[href*=${groups}]]`)[1].innerHTML;
这篇关于如何使用queryselector选择位于属性内的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文