How to find out which radio button is selected using jQuery?
Hello everyone! I'm a beginner in web development and can't figure out radio buttons. I have a simple form with gender selection: male, female, and other. I need that when the "Submit" button is clicked, the value of the selected radio button is output to the console.
Here's my HTML:
```html
```
I tried writing this jQuery code:
```javascript
$('#submitBtn').click(function() {
var selectedValue = $('input[type=radio]').val();
console.log(selectedValue);
});
```
But it
No answers yet.
Log in to leave an answer
Blogs