How to call jQuery function on radio button change event?

I would like to call jQuery function on <input type='radio' /> button change. How can I do it?

I have to show, hidden <div> on radio button value='yes', so if I have two <div>, with id div1 & div2, I would like to show div2 when radio value is "yes", here is my example HTML

               <input type="radio" id="128" name="53" value="Yes" class="RadioBtn">Yes              
               <input type="radio" id="129" name="53" value="No" class="RadioBtn">No                

<div id="1">

<div id="2">
data 2 

Would need jQuery code to show div on radio button change, using a function.

Asked by:- jaiprakash
: 4183 At:- 3/16/2018 2:37:46 PM
jQuery radio button change

2 Answers
profileImage Answered by:- jaya

You can use the on 'change' event of the radio button and show/hide div depending on your need.


$(document).ready(function() {
    $('input[type=radio][name=53]').change(function() {
        if (this.value == 'Yes') {
        else if (this.value == 'No') {

Here is the working fiddle link

Note: I am hiding <div> 2 on load.

At:- 3/17/2018 1:29:16 PM
thanks for your easy solution and fiddle link 0
By : jaiprakash - at :- 3/23/2018 7:14:33 AM

profileImage Answered by:- vikas_jk

You can also use Inline onchange Javascript method

               <input type="radio" id="128" name="53" value="Yes" class="RadioBtn"  onchange="changeRadio('Yes')">Yes              
               <input type="radio" id="129" name="53" value="No" class="RadioBtn" onchange="changeRadio('No')">No        


function changeRadio(val){

check fiddle:


At:- 12/15/2022 3:22:48 PM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use