Use jQuery to find the label for a selected control or textbox Use jQuery to find the label for a selected control or textbox jquery jquery

Use jQuery to find the label for a selected control or textbox


Use the attribute selector [] like [for='+ this.id +'], where this.id is the ID of the currently focused label

$('input').on("focus", function() {   var labelText = $('label[for='+  this.id  +']').text();   console.log( labelText );  });
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><label for="inp">This Is My Label Value</label><input  id="inp" type="text" >