In this article, Iwill show you how to know which Radio button selected using JQuery. You can getradio button selected value by group name of radio button using checkedproperty.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('input').on('change', function () {
alert($('input[name=Countries]:checked').val());
});
});
</script>
<form id="Form1">
Select your Country:
<br />
<input type="radio" name="Countries" value="India" />
India
<br />
<input type="radio" name="Countries" value="Pakistan" />
Pakistan
<br />
<input type="radio" name="Countries" value="Bangladesh" />
Bangladesh
<br />
</form>
Description:
In above example, ifthe user selects the Country from the country List you can get the selectedcountry by group name (Countries) using checked property.
Output:
Post your comments / questions
Recent Article
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
- ModuleNotFoundError: No module named 'openpyxl' - Python
- How to get thumbnail from vimeo video URL in Python?
- Remove all special characters, punctuation except spaces from string - Python
- OSError: cannot write mode RGBA as JPEG- Python
- expected str, bytes or os.PathLike object, not JpegImageFile - Python
Related Article