title: AJAX return jquery loop html div
body: <p>i have HTML below being returned from Ajax success i am have been trying to do so far without success is to loop over the divs get the div id and then create a button for each on the jquery dialog box once the user clicks the button the HTML from within the div will be applied to a form.</p>
  
  <p>the code below works but i have to filter out the content for each button but there is not always the same amount of divs there could be none for one person and 5 for another </p>
  
  <p>i have tried to use jquery.each </p>
  
  <p>i think someone would know how to loop thought these divs and create a button var for each one</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div class="target" id="1" &gt;
          &lt;p id="A1"&gt;04:00&lt;/p&gt;
          &lt;p id="A2"&gt;15:00&lt;/p&gt;
          &lt;p id="A3"&gt;00:16&lt;/p&gt;
          &lt;p id="A4"&gt;2&lt;/p&gt;
          &lt;p id="A5"&gt;10&lt;/p&gt;
          &lt;p id="A6"&gt;2&lt;/p&gt;
          &lt;p id="A7"&gt;10.73&lt;/p&gt;
          &lt;p id="A8"&gt;430.01&lt;/p&gt;
          &lt;p id="A9"&gt;0&lt;/p&gt;
          &lt;p id="NS"&gt;0&lt;/p&gt;
          &lt;p id="A10"&gt;0&lt;/p&gt;
          &lt;p id="A11" &gt;0.73&lt;/p&gt;
          &lt;p id="B1" &gt;448&lt;/p&gt;
          &lt;p id="B2" &gt;found&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="target" id="2" &gt;
          &lt;p id="A1"&gt;05:00&lt;/p&gt;
          &lt;p id="A2"&gt;13:00&lt;/p&gt;
          &lt;p id="A3"&gt;00:25&lt;/p&gt;
          &lt;p id="A4"&gt;3&lt;/p&gt;
          &lt;p id="A5"&gt;10&lt;/p&gt;
          &lt;p id="A6"&gt;2&lt;/p&gt;
          &lt;p id="A7"&gt;7.58&lt;/p&gt;
          &lt;p id="A8"&gt;263.71&lt;/p&gt;
          &lt;p id="A9"&gt;0&lt;/p&gt;
          &lt;p id="NS"&gt;0&lt;/p&gt;
          &lt;p id="A10"&gt;0&lt;/p&gt;
          &lt;p id="A11" &gt;0.00&lt;/p&gt;
          &lt;p id="B1" &gt;447&lt;/p&gt;
          &lt;p id="B2" &gt;found&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="target" id="3" &gt;
          &lt;p id="A1"&gt;05:00&lt;/p&gt;
          &lt;p id="A2"&gt;12:00&lt;/p&gt;
          &lt;p id="A3"&gt;01:00&lt;/p&gt;
          &lt;p id="A4"&gt;3&lt;/p&gt;
          &lt;p id="A5"&gt;06&lt;/p&gt;
          &lt;p id="A6"&gt;2&lt;/p&gt;
          &lt;p id="A7"&gt;6.00&lt;/p&gt;
          &lt;p id="A8"&gt;265.62&lt;/p&gt;
          &lt;p id="A9"&gt;0&lt;/p&gt;
          &lt;p id="NS"&gt;0&lt;/p&gt;
          &lt;p id="A10"&gt;0&lt;/p&gt;
          &lt;p id="A11" &gt;0.00&lt;/p&gt;
          &lt;p id="B1" &gt;446&lt;/p&gt;
          &lt;p id="B2" &gt;found&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JQUERY</p>
  
  <pre><code>   success:function(html){
  
  var button1 = {
       text: "Edit "+$($(html).filter('#1').html()).filter('#A1').text(),click: function() {
                                  var start = $($(html).filter('#1').html()).filter('#A1').text();
                                  $("#start").val(start);
                                  var finish = $($(html).filter('#1').html()).filter('#A2').text();
                                  $("#finish").val(finish);
                                  var breaktime = $($(html).filter('#1').html()).filter('#A3').text();
                                  $("#break").val(breaktime);
                                  var grade = $($(html).filter('#1').html()).filter('#A4').text();
                                  $("#grade").val(grade);
  },
  var button2 = {
       text: "Edit "+$($(html).filter('#2').html()).filter('#A1').text(), click: function() { 
                                  var start = $($(html).filter('#2').html()).filter('#A1').text();
                                  $("#start").val(start);
                                  var finish = $($(html).filter('#2').html()).filter('#A2').text();
                                  $("#finish").val(finish);
                                  var breaktime = $($(html).filter('#2').html()).filter('#A3').text();
                                  $("#break").val(breaktime);
                                  var grade = $($(html).filter('#2').html()).filter('#A4').text();
                                  $("#grade").val(grade);
  },
            }
  </code></pre>