title: Adjusting HTML inside iFrame - Javascript Not Working
body: <p>I have been looking up javascript/iFrame posts on StackOverflow for about 45 minutes and I've gathered some great resources, however I cannot get the javascript to function correctly inside an iFrame. I've attached two screenshots from a website that I have iFramed inside my own. The iFrame pops up with a menu open that takes up 60% of the frame. I'd like to add a class to the menu to close it automatically upon my page loading. I've got the right JS, I think, but I can't get it to function. The class will not add at all.</p>
  
  <p><a href="https://i.stack.imgur.com/gKBZb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gKBZb.jpg" alt="Menu opened"></a>
  <a href="https://i.stack.imgur.com/ar2xI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ar2xI.jpg" alt="Menu closed"></a>
  This is my iFrame and Javascript to change the div ID to "expanded" class. I know it sounds silly, but expanded is the class name for the closed menu. Any help would be appreciated! Thanks.</p>
  
  <pre><code>&lt;iframe src="http://dayzdb.com/map#2.065.045" style="width:500px; height:300px;" id="dayzdb"&gt;&lt;/iframe&gt;
  
        &lt;script&gt;$("#dayzdb").contents().find("#mapContainer").addClass("expanded")&lt;/script&gt;
  </code></pre>
  
  <p>In lieu of posting the HTML (since it's long) I have posted the website link where you can inspect element on the navbar to see it.</p>
  
  <p><a href="http://dayzdb.com/map" rel="nofollow noreferrer">http://dayzdb.com/map</a></p>