单选框radio无法正确选中

1、案例

<div class="form-group ">
    <label class="col-md-3 control-label" for="role">用户状态
    </label>
    <div class="col-md-9" id="enablestate">
        <label class="radio-inline">
            <input type="radio" name="enabled" value="1"> 启用
        </label>
        <label class="radio-inline">
            <input type="radio" name="enabled" value="0"> 停用
        </label>
    </div>
</div>

2、js

var enabled = rowDataUserTable.enabled;  //用户状态
//清除选中状态有效
$('input:radio[name="enabled"]').prop('checked',false);
//列表中单次选中有效,切换row选中状态有问题
$("input[name='enabled'][value="+enabled+"]").attr("checked",true);
//最终解决
$("input[type=radio][name='enabled'][value='"+enabled+"']").prop("checked",true);
原文地址:https://www.cnblogs.com/x-jingxin/p/13043048.html