How can I select the correct child element hidden input value based upon the context of the current selected button?
<p>I trying to put together a 5 day checklist app. The check list app has 5 divs that span across the page horizontally. Each div represents a day. Each div represents a day of the week and each div contains a hidden input field which holds a date value for for that particular day. Each div also has a check-list button and when the user clicks on that button the task list is removed and a form appears in its place to add a task. I'm trying to capture the value of the hidden input field, which is the date for that particular div. However, even though I'm using the "this" keyword, no matter which check-list button I click, I'm getting back the current date only. Which is the input value in the first div. How can I select the unique input value(the date) based upon which check-list button I click?</p>

<p>jquery:</p>

<pre><code>$(".task-btn").click(function(){
    // Setting form to the clone I want to acces in .on()
    var refdate = $(this).closest('#replace').children('.hidden-date').val();
    console.log(refdate);
});
</code></pre>

<p>html and php:</p>

<pre><code>&lt;?php 
  $date = date("F j, Y");
  $refDate = date("Y-m-d");
  $counterForLi = 0;
?&gt;
&lt;div id="replace"&gt;
              &lt;input type="hidden" name="thedate" class="hidden-date" value="&lt;?php echo $refDate; ?&gt;"&gt;
              &lt;h2 class="day"&gt;&lt;/h2&gt;
                &lt;h4 class="thedate"&gt;
                  &lt;?php
                    if ($counter &gt; 0) {
                      $tomorrow = mktime(0, 0, 0, date("m"), date("d")+$counter, date("y"));
                      $refDate = date("Y-m-d", $tomorrow);
                      $date = date("F j, Y", $tomorrow);
                      echo $date;
                    } else {
                      echo $date;
                    }
                  ?&gt;
                &lt;/h4&gt;
                &lt;?php echo $refDate; ?&gt;

                &lt;div class="btn-group"&gt;
                  &lt;button class="btn task-btn"&gt;Add Task&lt;/button&gt;
</code></pre>

<p>Note: I echoed out the date for each div and made sure there wasn't a problem with the php.</p>
