jQuery change label text on radio checked
How to change the Label text based on radio checked value
by AnilAwadh
HTML
<table>
<tr>
<td colspan="2">
<span id="labelMsgForRadioClick">Select your choice</span>
</td></tr>
<tr>
<td>
<input type="radio" value="hagh" checked="checked" name="reg">حقیقی</input>
</td>
<td>
<input type="radio" value="hogh" name="reg">حقوقی</input>
</td>
</tr>
</table>
JavaScript
$('input[name=reg]').change(function() {
switch ($('input[name=reg]:checked').val()) {
case 'hagh':
$('#labelMsgForRadioClick').text('first radio was clicked');
break;
case 'hogh':
$('#labelMsgForRadioClick').text('second radio was clicked');
break;
default:
$('#labelMsgForRadioClick').text('select your choice');
}
});