title: How to use jquery from parent inside a child window
body: <p>If you look at the reference link, it has an iframe that accesses its parent reference for jquery. Is this same thing possible if, instead of an iframe, it was a child window?</p>
  
  <p><strong>P.S.</strong><br>
  Despite the unknown reason for syntax error the click handler still works if I continue through the error?</p>
  
  <p><strong>syntax error</strong><br>
  I'm getting a non-descriptive syntax error on <code>return window.opener.$</code> when it's called by <code>$('#Button1').</code> So, I'm not getting to my alert.  </p>
  
  <p><strong>parent window</strong>  </p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
      &lt;input id="Parent_Button1" type="button" value="Pop out window" /&gt;
  
      &lt;script&gt;
          window.onload = function () {
              $('#Parent_Button1').on('click', function () {
                  window.open('pop-out-win.aspx', '', 'width=400,height=300');
              });
          }
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>child window</strong><br>
  
  </p>
  
  <pre><code>&lt;input id="Button1" type="button" value="push me" /&gt;
  
  &lt;script&gt;
      window.onload = function () {
          if (typeof (jQuery) == "undefined") {
              var iframeBody = document.getElementsByTagName("body")[0];
              var jQuery = function (selector) { return window.opener.$(selector, iframeBody); };
              var $ = jQuery;
  
              var btn1 = $('#Button1');
  
              btn1.on('click', function () {
                  alert('achievement unlocked!')
              });
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p><strong>reference</strong><br>
  <a href="https://stackoverflow.com/a/10950158/139698">https://stackoverflow.com/a/10950158/139698</a></p>