What would be the javascript below to select the checkbox for value 0?
<input name="bootproto" id="bootproto" type="radio" value="0" key="bootproto">
I tried using
$('input[name="bootproto"]').click()
but it didnt seem to work.
Sterling Archer :
$(\"#bootproto\").prop(\"checked\",true);\n\n\nSince you're using jquery, just set the property \"checked\" to true (I don't see why you're name selecting when you have a perfectly good ID there as well)\n\nIf you want to check it ONLY if value=0, add an if statement before this.",
2013-11-20T17:47:02
Ankit Tyagi :
document.getElementById('bootproto').checked = true;\n\n\nOR\n\n $('#bootproto').prop('checked',true);\n",
2013-11-20T17:46:53
soniccool :
I figured out that $('input[value=\"0\"]').click() seemed to work for me.",
2013-11-20T17:49:16
Rajaprabhu Aravindasamy :
Try this,\n\n$('input[name=\"bootproto\"]').attr('checked',true);\n\n\nChecked is actually an attribute of the input tag of type radio, So that you can use the .attr() function to set its checked attribute as true.\n\nDEMO",
2013-11-20T17:47:05
Andy :
You don't mention that you're using jQuery even tho you've apparently tried the syntax. On the off-chance you're not using it, try:\n\nvar i = document.querySelector('input[value=\"0\"]').checked = true;\n",
2013-11-20T17:54:44