Radio button is checked or not with jQuery

JavaScript

$('#buttoncheck').click(function(){
    if ($("input[name='name']").is(':checked')) {
        $('.radiobutton').html("Radio button is checked and it's value is "+$("input[name='name']:checked").val())
    }
    else {
        $('.radiobutton').html('Radio button is Not checked')
    }
    // return false  use as per you need
    return false;
})

HTML

<form>
    <p>
        <label>
            <input type="radio" name="name" value="Yes"> Yes
        </label>
        <label>
            <input type="radio" name="name" value="No" > No 
        </label>
    </p>
    <p>
        <input type="reset" value="Reset">
        <input type="submit" id="buttoncheck" value="Check">
    </p>
    <p class="radiobutton"></p>
</form>

Preview snippets

Run jQuery

Copyright 2024 by WebiBeris.com. All Rights Reserved.