screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>jQuery Radio Button Example</title> <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> </head> <body> <h3>Jquery Get Radio Button Selected Value | Checked Value</h3> <form class="gender-form"> <label> <input type="radio" name="gender" value="male" class="gender-option"> Male </label> <label> <input type="radio" name="gender" value="female" class="gender-option"> Female </label> <label> <input type="radio" name="gender" value="other" class="gender-option"> Other </label> </form> <!-- Display output on the webpage --> <div id="output"></div> <script> $(document).ready(function() { // Event listener for radio button change $('.gender-form .gender-option').change(function() { // Get the selected value var selectedValue = $('.gender-form .gender-option:checked').val(); // Display the selected value on the webpage $('#output').text('Selected Gender: ' + selectedValue); }); }); </script> </body> </html>