jquery - How to get text of a label using for -


how can text of label via for selector? here's label:

<label for="startdate">iteration start</label> 

here's i've tried:

$("label[for='startdate']").text(); 

but returns "".

can help?

thanks in advance!

alert($('label[for=startdate]').text())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <label for="startdate">iteration start</label>

use attr selector

description: selects elements have specified attribute value equal value.