How to Check a Radio Button Using jQuery

To check a radio button in jQuery, we make use of prop() function.  This function is only available in jQuery 1.6 or higher.  For jQuery 1.5 or lower, please make use of attr() function.  Example is given below for jQuery 1.6 or higher.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<head>
<title>jQuery Tutorial </title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
//Function to Check Radio Button.
function Check(){
$('#myRadio').prop("checked", true) ;
}
</script>
</head>
<body>
My Radio Button: <input id="myRadio" type="radio" />
<input type="button" value="Check" onclick="Check()"/>
</body>
</html>
<!DOCTYPE html> <html> <head> <title>jQuery Tutorial </title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> //Function to Check Radio Button. function Check(){ $('#myRadio').prop("checked", true) ; } </script> </head> <body> My Radio Button: <input id="myRadio" type="radio" /> <input type="button" value="Check" onclick="Check()"/> </body> </html>
<!DOCTYPE html>
<html>
<head>
<title>jQuery Tutorial </title>
 
<script src="http://code.jquery.com/jquery-latest.js"></script>
 
<script type="text/javascript">
 
//Function to Check Radio Button.
function Check(){
    
    $('#myRadio').prop("checked", true) ;
}
 
</script>
 
</head>
<body>
 
My Radio Button:  <input id="myRadio" type="radio" />
<input type="button" value="Check" onclick="Check()"/>
 
</body>
</html>