How to set radio button status with JavaScript

前端 未结 8 1281
抹茶落季
抹茶落季 2020-12-04 21:11

What method would be best to use to selectively set a single or multiple radio button(s) to a desired setting with JavaScript?

8条回答
  •  日久生厌
    2020-12-04 21:33

    You can also explicitly set value of radio button:

    Man Woman

    with the following script:

    document.gendersForm.gender.value="F";
    

    and corresponding radio button will be checked automatically.

    Look at the example on JSFiddle.

提交回复
热议问题