本文介绍了如何以编程方式设置或重置复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目的:选中或取消选中某个复选框时,程序必须根据编程规则更改许多其他复选框.
Purpose: when a particular checkbox is checked or unchecked, the program must change a number of other checkboxes according to programmed rules.
<input type="checkbox" id="chkbox" (change)="onChangeChk($event)">Test Checkbox
onChangeChk($event) {
$event.srcElement.value = "on"; // or "off"
}
无论onChangeChk如何设置,该复选框均保持其原始状态.
The checkbox remains in its original state no matter how the onChangeChk sets it.
感谢您的帮助.:-)
Thanks for you help on this.:-)
推荐答案
您可以将输入元素的checked
属性分配为true或false.
You can assign the checked
property of your input element to true or false.
像这样:
onChangeChk($event) {
$event.srcElement.checked = true; // or false
}
另请参见此处: https://www.w3schools.com/jsref/prop_checkbox_checked.asp
这篇关于如何以编程方式设置或重置复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!