MDN self-hosted library · e01.org

DocumentFragment: querySelector() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
const el = documentfragment.querySelector(".myclass");
html
<div id="foo\bar"></div>
<div id="foo:bar"></div>
js
document.querySelector("#foo\bar"); // Does not match anything
document.querySelector("#foo\\\\bar"); // Match the first div
document.querySelector("#foo:bar"); // Does not match anything
document.querySelector("#foo\\:bar"); // Match the second div