JavaScript for WordPress Forums Vanilla JavaScript why use query selector Reply To: why use query selector

Zac Gordon

Try starting with this markup:

  <div id="content">
    <div class="entry-content">
      <h1 class="entry-title">Zac Gordon</h1>
      <p>Zac Gordon is a professional educator with years&nbsp;of experience teaching in the classroom, leading&nbsp;workshops, giving talks and recording&nbsp;online courses.</p>

and then try to do the equivalent of this

var header = document.querySelector( '#content .entry-content h1' ); 


– getElementById
– getElementsByClassName
– getElementsByTagName