admin管理员组文章数量:1332339
I am writing software that has to work with the dom of a third-party web-app that I don't control. Some of the class names have parameter, eg class="view_box(200px)"
. I'm guessing these class names are Sass/Less mixins/arguments?
document.querySelector
doesn't seem to like .view_box(200px)
as a valid class selector, and simply querying .view_box
doesn't return any of the elements that have the full string with argument as their class.
I tried escaping the parens as \(
and \)
. I even tried URL encoding them as %28
and %29
. I get the error Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '.view_box(200px)' is not a valid selector.
I am writing software that has to work with the dom of a third-party web-app that I don't control. Some of the class names have parameter, eg class="view_box(200px)"
. I'm guessing these class names are Sass/Less mixins/arguments?
document.querySelector
doesn't seem to like .view_box(200px)
as a valid class selector, and simply querying .view_box
doesn't return any of the elements that have the full string with argument as their class.
I tried escaping the parens as \(
and \)
. I even tried URL encoding them as %28
and %29
. I get the error Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '.view_box(200px)' is not a valid selector.
1 Answer
Reset to default 11You need to pass a literal backslash into the argument:
document.querySelector(".view_box\\(200px\\)")
本文标签: javascriptdocumentquerySelector get class name containing parenthesesStack Overflow
版权声明:本文标题:javascript - document.querySelector get class name containing parentheses - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742330960a2454685.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论