js document queryselectorall code example
Example 1: js foreach querySelectorAll
const allSpanElements = document.querySelectorAll('span');
allSpanElements.forEach((spanElement) => {
// Here comes the Code that should be executed on every Element, e.g.
spanElement.innerHTML = "This Content will appear on every span Element now";
});
Example 2: js queryselectorall
var matches = document.querySelectorAll("p");
Example 3: document.queryselector
<div id="foo\bar"></div>
<div id="foo:bar"></div>
<script>
console.log('#foo\bar');
document.querySelector('#foo\bar');
console.log('#foo\\bar');
console.log('#foo\\\\bar');
document.querySelector('#foo\\\\bar');
document.querySelector('#foo:bar');
document.querySelector('#foo\\:bar');
</script>