Checking Value of Radio Button Group via JavaScript?

前端 未结 8 660
清歌不尽
清歌不尽 2020-12-12 20:36

This may seem silly and downright stupid but I can\'t seem to figure out how to check the value of a radio button group in my HTML form via JavaScript. I have the following

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 20:54

    To get the value you would do this:

    document.getElementById("genderf").value;
    

    But to check, whether the radio button is checked or selected:

    document.getElementById("genderf").checked;
    

提交回复
热议问题