how to queryselector code example

Example 1: queryselector

var el = document.querySelector(".myclass");

Example 2: 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';

Example 3: queryselector for jquery

var x = $(".yourclass")[0];
console.log('jq' + x);
var y = document.querySelector(".yourclass");
console.log('js' + y);

Example 4: queryselector

document.querySelector(".example");

Tags:

Java Example