Q:

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';
5
const content = document.querySelector('.content');

const towns = ['Helsinki', 'Espoo', 'Vantaa'];

towns.forEach(city => {
    content.innerHTML += `<p>${city}</p>`;
});
1
var el = document.querySelector(".myclass");
2
const para = document.querySelectorAll('p');
1
var x = $(".yourclass")[0];
console.log('jq' + x);
var y = document.querySelector(".yourclass");
console.log('js' + y);
0
document.querySelector(".example");
-1

New to Communities?

Join the community