Skip to content
Advertisement

On page load check a radio button based on its id using Javascript

I want on page load to check a radio button by default using pure javascript. Here is my code:

JavaScript
JavaScript

but it doesn’t work. On page load the first radio button with the id=”btn-Man” should be checked. What in the world i ‘m doing wrong ?

Advertisement

Answer

Try without ‘.value’ like:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement