title: Get last child of div in Javascript function
body: <p>I am taking a fairly simple piece of code and wrapping into a function, the code builds a slide out menu from the items inside a div.  I'm now trying to get the last child from a div:</p>
  
  <pre><code>experimentOne('#experimentOne');
  
     function experimentOne(masterContainer) {
     var experimentOneMenuButton = $('masterContainer :last-child');
     ... etc
  </code></pre>
  
  <p>However, this returns [] in the log.  When I check the width, instead of the 100px it should be, it's 1420 which I'm guessing is the window width.</p>
  
  <p>If I just get the last child of the ID by coding it in everything is fine, but I want the function to be as reusable as possible.</p>
  
  <p>Thanks.</p>