javascript radio button onclick show hide code example

Example 1: jQuery check a radio button

// jQuery version 1.6 or above use:  
$("#myRadioID").prop("checked", true);
 
//jQuery versions below 1.6 use:
$("#myRadioID").attr('checked', 'checked');

Example 2: how to detect a button click in javascript

if(document.getElementById('button').clicked == true)
{
   alert("button was clicked");
}

Example 3: javascript uncheck radio button

document.getElementById("radioButtonID").checked = false; //uncheck a radio button
document.getElementById("radioButtonID").checked = true; //check a radio button