title: Jquery getting the value of a parent element input when checking a child checkbox
body: <p>I have this set of forms, when the user checks the input, I need to get the value that is outside this div, basically a parent div, try it to do it using .parent() and then find but could not make it work, not sure what do I am doing wrong, I have a js <a href="http://jsfiddle.net/creativestudio/bCgeD/2/" rel="nofollow">http://jsfiddle.net/creativestudio/bCgeD/2/</a></p>
  
  <p>This is my js:</p>
  
  <pre><code>                    function set_index_id_checkbox() {
                          $("input:checkbox[name='like']").each(function(index){
                              var currElem = $(this);
                              var prevLabel = currElem.next();
                              currElem.attr("id", this.id + index);
                              prevLabel.attr("for", prevLabel.attr("for") + index);
                          });
                      }
  
                      set_index_id_checkbox();
  
  
                      function getValues(){
                          $("input:checkbox[name='like']").click(function(){
                              if (this.checked) {
                                 $(this).closest('.reply-form').find('.feedback_nid').text(this.value);
                              } else {
                                // ...
                              }
                         });
                      } getValues();
  </code></pre>
  
  <p>and this is my html: 
              </p>
  
  <pre><code>        &lt;input type="hidden" class="feedback_nid" value="form a 111"&gt;
          &lt;input type="hidden" class="branch_nid" value="form a 222"&gt;
  
          &lt;div class="block"&gt;
              &lt;!-- value --&gt;
              &lt;span class="info-item float-left value"&gt;
                  &lt;span class="likes"&gt;value&lt;/span&gt;
              &lt;/span&gt;&lt;!-- /.value --&gt;
              &lt;!-- checkbox --&gt;
              &lt;div class="btn like-checkbox float-right"&gt;
                       &lt;input id="like" class="like" type="checkbox" name="like" value="33"&gt;
                       &lt;label class="like" for="like"&gt;like 1&lt;/label&gt;
              &lt;/div&gt;&lt;!-- /checkbox --&gt;
          &lt;/div&gt;
  
          &lt;/div&gt;
  
          &lt;div class="reply-form"&gt;
          &lt;input type="hidden" class="feedback_nid" value="form a 111"&gt;
          &lt;input type="hidden" class="branch_nid" value="form a 222"&gt;
          &lt;div class="block"&gt;
              &lt;!-- value --&gt;
              &lt;span class="info-item float-left value"&gt;
                  &lt;span class="likes"&gt;value&lt;/span&gt;
              &lt;/span&gt;&lt;!-- /.value --&gt;
              &lt;!-- checkbox --&gt;
              &lt;div class="btn like-checkbox float-right"&gt;
                       &lt;input id="like" class="like" type="checkbox" name="like" value="45"&gt;
                       &lt;label class="like" for="like"&gt;like 2&lt;/label&gt;
              &lt;/div&gt;&lt;!-- /checkbox --&gt;
          &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="reply-form"&gt;
          &lt;input type="hidden" class="feedback_nid" value="form a 111"&gt;
          &lt;input type="hidden" class="branch_nid" value="form a 222"&gt;
          &lt;div class="block"&gt;
              &lt;!-- value --&gt;
              &lt;span class="info-item float-left value"&gt;
                  &lt;span class="likes"&gt;value&lt;/span&gt;
              &lt;/span&gt;&lt;!-- /.value --&gt;
              &lt;!-- checkbox --&gt;
              &lt;div class="btn like-checkbox float-right"&gt;
                       &lt;input id="like" class="like" type="checkbox" name="like" value="66"&gt;
                       &lt;label class="like" for="like"&gt;like 3&lt;/label&gt;
              &lt;/div&gt;&lt;!-- /checkbox --&gt;
          &lt;/div&gt;
          &lt;/div&gt;​
  </code></pre>