title: How to target element by data attribute using Javascript
body: <p>I have a div element with a data attribute that I need to use to select that element but I'm drawing a blank on how to do that.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div class="element" data-id="123456789"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>var element = document.body.querySelector('.element[data-id=123456789]');
  </code></pre>