document.queryselectorAll code example
Example 1: selet all elemnts
var elems = document.body.getElementsByTagName("*");
Example 2: class query css js all
var matches = document.querySelectorAll("div.note, div.alert");
Example 3: js queryselectorall
var container = document.querySelector("#test");
var matches = container.querySelectorAll("div.highlighted > p");
Example 4: query selector has clas
document.body.classList.add('thisClass');
// $('body').addClass('thisClass');
document.body.classList.remove('thatClass');
// $('body').removeClass('thatClass');
document.body.classList.toggle('anotherClass');
// $('body').toggleClass('anotherClass');
Example 5: js queryselector names
// This selects the first element with that name
document.querySelector('[name="your-selector-name-here"]');
Example 6: javascript queryselector
//Pretend there is a <p> with class "example"
const myParagraph = document.querySelector('.example');
//You can do many this with is
myParagraph.textContent = 'This is my new text';