How do I know which radio button is selected in jquery?

advertisements

This question already has an answer here:

  • How can I know which radio button is selected via jQuery? 29 answers

here this is my code... here i am generating radio button dynamically using php code...

my problem is how to get which radio button selected on click of addForm() function...

<div class="modal-body">
    <div> <input type="radio" name="form" value="Form-Name">Form-Name</div>
    <div> <input type="radio" name="form" value="Kalpit-Contact">Kalpit-Contact</div>
    <div> <input type="radio" name="form" value="Kalpit-Contact test">Kalpit-Contact test</div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    <button type="button" class="btn btn-primary" onclick="addForm()">Add Page</button>
</div>

Thanks in advance


var selectedValue = $("input[name=form]:checked").val();