js queryselector radio checked 1

js queryselector radio checked

document.querySelector('[name="your_name"]:checked').value;

Here is what the above code is Doing:
1. We’re selecting the form element by its id.
2. We’re selecting the input element with the name attribute of your_name.
3. We’re selecting the input element with the name attribute of your_name that is checked.
4. We’re getting the value of the input element with the name attribute of your_name that is checked.

Similar Posts