title: Accessing elements of parent window from iframe (jquery)
body: <p>I have several dinamically created divs, with the same elements inside:</p>
  
  <pre><code>&lt;div id="(dinamic_id_1)"&gt;
      &lt;div class="(element_1)"&gt;Some text here&lt;/div&gt;
      &lt;input class="(element_2)" /&gt;
      &lt;iframe class="(element_3)" src="form.php?id=(dinamic_id_1)" /&gt;
  &lt;/div&gt;
  
  &lt;div id="(dinamic_id_2)"&gt;
      &lt;div class="(element_1)"&gt;Some text here&lt;/div&gt;
      &lt;input class="(element_2)" /&gt;
      &lt;iframe class="(element_3)" src="form.php?id=(dinamic_id_2)" /&gt;
  &lt;/div&gt;
  
  ...
  </code></pre>
  
  <p>And there's a form within the iframe that would look something like this:</p>
  
  <pre><code>&lt;form id="(dinamic_id)" &gt;
      &lt;input class="(class_input)" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And my jquery function:</p>
  
  <pre><code>$(".class_input").change(function() {
      $(this).closest("form").submit();
  });
  </code></pre>
  
  <p>There are other actions that I want to execute on submit on the parent window, on the elements contained within the div that shares the same id as the form. I got to get the html within the parent div like this:</p>
  
  <pre><code>var parent_div = $("div#"+$(this).closest("form").attr("id"), parent.document);
  alert($(parent_div).html());
  </code></pre>
  
  <p>But I can't get to the elements within the div, for example:</p>
  
  <pre><code>var parent_div = $("div#"+$(this).closest("form").attr("id"), parent.document);
  alert($(parent_div+" .element_1").html());
  </code></pre>
  
  <p>or </p>
  
  <pre><code>var parent_div = $("div#"+$(this).closest("form").attr("id")+" .element_1", parent.document);
  alert($(parent_div).html());
  </code></pre>
  
  <p>Return null instead of "Some text here".</p>