I have those two html radio buttons and textarea. I basically want to enable the textarea when Yes is selected, and disable it otherwise.
<input type='radio' id='comment' name='comment' value='Yes'>Yes
<input type='radio' id='comment' name='comment' value='No' checked="checked">No
<textarea id='writehere' name='writehere' cols='25' rows='2'></textarea>
Below is my jQuery. The commands only occur when I put it back to value No. But I want those commands to be executed everytime the “comment” is changed, regardless of Yes or No.
$('#writehere').attr('disabled','disabled');
$('#comment').change(function(){
if ($('#comment').val() == 'No')
$('#writehere').attr('disabled','disabled');
if ($('#comment').val() == 'Yes')
$('#writehere').removeAttr('disabled');
});
you have 2 id that are the same that’s your problem.
It’s not W3C valid and in those situation jQuery will only proceed the first id.