Check Radio Button Using jQuery


Check Radio Button Using jQuery – There are many ways to check a radio button. Here in this tutorial we are going to explain how you can check radio button in jQuery. We Will Explain this with example and demo.


Check Radio Button Using jQuery Example

Checking radio button in jQuery is very simple. You can check radio button simply as below –

Check Radio Button Using jQuery: Example

<!DOCTYPE html>
<html>
<head>
<title>jQuery Scrolltop Demo example</title>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.4.min.js">
 </script>
<script type="text/javascript">
function checkRadio(){
$("#radio2").prop("checked", true);
}
</script>
 </head>	
<body>
<form>    
        <input type='radio' id='radio1' name='type' value='1' />
        <input type='radio' id='radio2' name='type' value='2' />
        <input type='radio' id='radio3' name='type' value='3' /> 
</form>

<button onclick="checkRadio()">Check Radio</button>  
</body>
</html>                                                                                                                                                      

Try it »

The above example will select the radio button radio2 and set the property as checked. If you run the above example it will produce output something like this –

Check Radio Button Using jQuery Example


Advertisements

Add Comment

📖 Read More