jQuery set radio button

前端 未结 12 2018
执笔经年
执笔经年 2020-12-02 11:12

I am trying to set a radio button. I want set it by using the value or the id.

This is what I\'ve tried.

$(\'input:radio[name=cols]\'+\" #\"+newcol).         


        
12条回答
  •  时光取名叫无心
    2020-12-02 11:18

    In my case, radio button value is fetched from database and then set into the form. Following code works for me.

    $("input[name=name_of_radio_button_fields][value=" + saved_value_comes_from_database + "]").prop('checked', true);
    

提交回复
热议问题