title: JavaScript find an element like jQuery's .find()
body: <p>I have this HTML:</p>
  
  <pre><code>&lt;div class="parent"&gt;
     &lt;div&gt;&lt;/div&gt;
     &lt;p&gt;
        &lt;img src="#" widht="500"&gt;
     &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What I need is to get the value of <code>img</code> width attribute, but with plain JavaScript.</p>
  
  <p>My js:</p>
  
  <pre><code>window.onload = function(){
          var width = document.querySelector('.parent &gt; p &gt; img').getAttribute('width');
          var img = document.querySelector('.parent &gt; p &gt; img');
          img.style.width = width+'px';
      };
  </code></pre>
  
  <p>But still I get this error: </p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'getAttribute' of null
  </code></pre>
  
  <p>So, the <code>img</code> is not found I guess.. How can I find the <code>img</code> from <code>.parent</code> <code>div</code>? </p>