Jquery get value from Radio Button

You need to change the value of category every time a user changes the selected radio button. Therefore you will need an event to trigger when the user clicks on a radio.


Fruit Name :


        <input type="radio" name="category" value="apple" id="apple" checked /> <label for="apple">Apple</label>
        <input type="radio" name="category" value="orange" id="orange" /> <label for="orange">Orange</label>
<h2>Fruit Name :</h2>
<div class="fruitName"></div>


var category = null;
$("input[name='category']").click(function() {
    category = this.value;

Copyright 2022 by WebiBeris.com. All Rights Reserved.