how to set radio option checked onload with jQuery

后端 未结 16 2094
陌清茗
陌清茗 2020-12-04 04:42

How to set radio option checked onload with jQuery?

Need to check if no default is set and then set a default

16条回答
  •  春和景丽
    2020-12-04 05:22

    Native JS solution:

     document.querySelector('input[name=gender][value=Female]').checked = true;
    

    http://jsfiddle.net/jzQvH/75/

    HTML:

     Male
    Female
    

提交回复
热议问题