1

I am trying to set a specific radio buttom item to be checked using JQuery when the page loads.

Can this be done with jquery?

Satch3000
  • 47,356
  • 86
  • 216
  • 346

4 Answers4

5
$(function () {    
  $("#myRadioId").prop("checked", true);
});
Rich O'Kelly
  • 41,274
  • 9
  • 83
  • 114
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
1

This is so easily googled, the best way to learn is to try it your self. We only get better by working things out.

http://api.jquery.com/ready/
http://api.jquery.com/prop/

$(document).ready(function() {
 $("#your id").prop("checked", true);

});
Dominic Green
  • 10,142
  • 4
  • 30
  • 34
0

$(document).ready(function() {
  $("#yourRadioButtonId").attr("checked", "checked");
//Or
  $("#yourRadioButtonId").prop("checked",true);

});

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
0
$(document).ready(function() {
$('radio-selector[name="the-value-to-set"]').attr('checked', 'checked');
});
redmoon7777
  • 4,498
  • 1
  • 24
  • 26