Select elements by attributes with ":" (colon)

Viewed 6065

In my project, there's a case where a library generates elements, and I need to select specific elements from there - which happen to contain an attribute with ":".
In other words, I ended up attempting to select using: document.querySelectorAll("[xml:space]").
But, when tested in Chrome, it didn't work, nor selecting using document.querySelectorAll("['xml:space']") - they both threw a DOMException:
http://i.imgur.com/GrjpL85.png

My question is, how to make the above selector return the list of the elements with xml:space attribute?
Thanks!

3 Answers

can also do

document.querySelectorAll('[id="xml:space"]')
Related