jQuery set radio button

前端 未结 12 2017
执笔经年
执笔经年 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:36

    Why do you need 'input:radio[name=cols]'. Don't know your html, but assuming that ids are unique, you can simply do this.

    $('#'+newcol).prop('checked', true);
    

提交回复
热议问题