Gabriel
Gabriel

Reputation: 81

jquery check radio button with certain value

I think, I make a simple mistake here:

$('.myRadioButtons').val('3121').attr("checked",true);

But this one does not work too:

$(':input[value="3121"]').attr("checked",true);

The same problem also with "prop" instead of "attr".

Thank you..

EDIT: Here is online: http://jsfiddle.net/WWC4G/1/

Upvotes: 3

Views: 5968

Answers (1)

Murali Murugesan
Murali Murugesan

Reputation: 22619

Try using below

$('input[value="3121"]').prop("checked",true)

  or

$('input[value="3121"]').attr("checked","checked")

Upvotes: 6

Related Questions