queryselectorall javascript end with code example
Example 1: js queryselectorall
var matches = document.querySelectorAll("p");
Example 2: javascript queryselectorall
<article class="article first">
<div class="wrapper">
<div class="oferts">
<div class="pro"></div>
<h1>This is the Pro Version</h1>
</div>
<div class="oferts">
<div class="normal"></div>
<h1>This is the normal Version</h1>
</div>
</div>
</article>
<script>
var articleFirst = document.querySelectorAll("article.first");
console.log(articleFirst)
var oferts = articleFirst[0].querySelectorAll(".oferts");
console.log(oferts)
</script>
Example 3: js querySelectorAll
// https://www.google.com/
// this puts a border around the 'a' tags of 'Google offered in' section.
// within this id find all the 'a' tags
var languages = document.querySelectorAll("#SIvCob a");
// loop through all the a tags a add a border to the tags
for(var i = 0; i < languages.length; i++){
document.querySelectorAll("#SIvCob a")[i].style.border = "1px solid black";
}
Example 4: js queryselectorall
elementList = parentNode.querySelectorAll(selectors);