how to set radio option checked onload with jQuery

后端 未结 16 2089
陌清茗
陌清茗 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

    This one will cause form.reset() failure:

    $('input:radio[name=gender][value=Male]').attr('checked', true);
    

    But this one works:

    $('input:radio[name=gender][value=Male]').click();
    

提交回复
热议问题