How to clear radio button in Javascript?

后端 未结 10 562
予麋鹿
予麋鹿 2020-12-02 19:57

I have a radio button named \"Choose\" with the options yes and no. If I select any one of the options and click the button labeled \"clear\", I need to clear the selected o

10条回答
  •  独厮守ぢ
    2020-12-02 20:21

    This should work. Make sure each button has a unique ID. (Replace Choose_Yes and Choose_No with the IDs of your two radio buttons)

    document.getElementById("Choose_Yes").checked = false;
    document.getElementById("Choose_No").checked = false;
    

    An example of how the radio buttons should be named:

     Yes
     No
    

提交回复
热议问题