title: How to get value of closest input in jQuery
body: <p>I cannot get the value of an input field -- tried over and over.</p>
  
  <p>Here's the HTML</p>
  
  <pre><code>&lt;div class="col-md-10 persStmtPad input-group" style="margin-top: 1.5em;margin-left:35px"&gt;
    &lt;input id="summerCourses1" name="summerCourses[]" type="text" placeholder="Summer Course" class="form-control input-md" value="ABcdEFG"&gt;
    &lt;div class="input-group-btn"&gt;
      &lt;button name="scButtonMinus" class="btn btn-default btn-md scClick" style="background-color:#efefef;color:#999;margin-top:12px" title="Delete this Prerequisite Course" value=""&gt;&lt;span class="glyphicon glyphicon-minus" aria-hidden="true"&gt;&lt;/span&gt;&lt;/button&gt;
      &lt;button name="scButtonPlus" class="btn btn-default btn-md scClick" style="background-color:#efefef;color:#999;margin-top:12px" title="Add another Prerequisite Course" value=""&gt;&lt;span class="glyphicon glyphicon-plus" aria-hidden="true"&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;&lt;!-- end input-group --&gt;
  </code></pre>
  
  <p>Here's the jQuery</p>
  
  <pre><code>$( '.scClick' ).on( 'click', function( event ) {
    console.log($(this).attr('name'));
    if( $( this ).attr( 'name' ) == 'scButtonMinus' ) {
      console.log($( this ).closest( 'input' ).val()); // returns "undefined"
      console.log($( 'input[id=summerCourses1]' ).val()); // returns "undefined"
      console.log($( this ).prevAll( 'input' ).val()); // returns "undefined"
      console.log($( this ).parent().find( 'input' ).val()); // returns "undefined"
  
      console.log($( this ).closest( 'input' ).attr('class')); // returns "undefined"
      console.log($( 'input[id=summerCourses1]' ).attr('class')); // returns "undefined"
      console.log($( this ).prevAll( 'input' ).attr('class')); // returns "undefined"
      console.log($( this ).parent().find( 'input' ).attr('class')); // returns "undefined"
  
      $( this ).closest( 'input' ).val( '' );
      $( 'input[id=summerCourses]' ).val( '' );
      //$( this ).closest( "div.input-group" ).addClass( "hideContentBlock" );
    }
    return false;
  });
  </code></pre>
  
  <p>All console log entries return "undefined"</p>