如何在淘汰赛中为单选按钮分配默认值
how to assign default value to the radio button in knockout
我想在页面加载时将一些值作为默认值分配给单选按钮
这是我的代码
<input type="radio" name="year-end-method"
id="calendar-radio"
data-bind="checked: Selectedgroup.Yearendtype" value="Calendar">
这对我不起作用
$('input:radio[name="year-end-method"]
[value="RealTime"]').prop('checked', true);
您需要在加载时将值设置为 true。
Yearendtype = ko.observable(true)
来自文档
For radio buttons, KO will set the element to be checked if and only
if the parameter value equals the radio button node’s value attribute.
更多详情请看here
我想在页面加载时将一些值作为默认值分配给单选按钮
这是我的代码
<input type="radio" name="year-end-method"
id="calendar-radio"
data-bind="checked: Selectedgroup.Yearendtype" value="Calendar">
这对我不起作用
$('input:radio[name="year-end-method"]
[value="RealTime"]').prop('checked', true);
您需要在加载时将值设置为 true。
Yearendtype = ko.observable(true)
来自文档
For radio buttons, KO will set the element to be checked if and only if the parameter value equals the radio button node’s value attribute.
更多详情请看here