jQuery set radio button

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

    The chosen answer works in this case.

    But the question was about finding the element based on radiogroup and dynamic id, and the answer can also leave the displayed radio button unaffected.

    This line does selects exactly what was asked for while showing the change on screen as well.

    $('input:radio[name=cols][id='+ newcol +']').click();
    

提交回复
热议问题