Using jquery, how do i check a radio button based on a variable value?

前端 未结 2 948
长发绾君心
长发绾君心 2021-02-19 10:14

I have a list of radio buttons. I need to make one of them checked based on the variable i have. How do i accomplish this? The problem is i have no control of what the radio but

2条回答
  •  执念已碎
    2021-02-19 11:09

    Try this:

    $('input[type=radio][value=' + preSelect + ']').attr('checked', true);
    

提交回复
热议问题