as said in the title for example:
<input id="User_Type_0" type="radio" name="User_Type" value="1" checked="checked" />
<label for="User_Type_0">User1</label>
<input id="User_Type_1" type="radio" name="User_Type" value="2" />
<label for="User_Type_1">User2</label>
how can I get the text:User 1
$('input:radio:checked').siblings('label:first').html()
UPDATE:
As pointed out by Victor in the comments section the previous selector will always select the first label. The next function should work:
$('input:radio:checked').next('label:first').html()
how about this?
var forLabel = $('input:radio:checked').attr("id");
$("label[for='" + forLabel + "']").text();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With