[英]Select elements by attributes with ":" (colon)
在我的項目中,有一個庫生成元素的情況,我需要從那里選擇特定元素 - 這些元素恰好包含一個帶有“:”的屬性。
換句話說,我最終嘗試使用: document.querySelectorAll("[xml:space]")
。
但是,當在 Chrome 中測試時,它不起作用,也沒有選擇使用document.querySelectorAll("['xml:space']")
- 他們都拋出了DOMException
:
http://i.imgur.com/GrjpL85.png
我的問題是,如何使上述選擇器返回具有xml:space
屬性的元素列表?
謝謝!
轉義:
通過在它前面加上雙反斜杠\\\\
document.querySelectorAll("[xml\\:space]")
看到這個:
也可以做
document.querySelectorAll('[id="xml:space"]')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.