0
Q:

javascript queryselector

<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>


<!-- You will get a NodeList as Output -->
<!-- Try to do : console.log(typeof(oferts)) And you will see the type-->
<script>
var articleFirst = document.querySelectorAll("article.first");
console.log(articleFirst)
var oferts = articleFirst[0].querySelectorAll(".oferts");
console.log(oferts)
</script>
0
//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
document.querySelector(".example");
-1

New to Communities?

Join the community