how to set radio option checked onload with jQuery

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

    //If you are doing it on javascript or a framework like backbone, you will encounter this a lot you could have something like this

    $MobileRadio = $( '#mobileUrlRadio' );
    

    while

    $MobileRadio.checked = true;
    

    will not work,

    $MobileRadio[0].checked = true;
    

    will.

    your selector can be as the other guys above recommended too.

提交回复
热议问题