如何取消选中另一个复选框上的复选框,以及如何将控件可见性设置为false

问题描述

|| 我编写了示例代码,以取消选中另一个复选框后的复选框。同时,我想根据复选框的选中或取消选中将控件的可见性设置为false,这就是我写的内容
<form name=\"formName\">
<input type=\"checkBox\" name=\"priorityHigh\"
    onclick=\"if(this.checked) {document.formName.priorityLow.checked=false;}\">High Priority

<input type=\"checkBox\" name=\"priorityLow\"
    onclick=\"if(this.checked) {document.formName.priorityHigh.checked=false;}\">Low Priority

<asp:TextBox ID=\"txtLastName\" runat=\"server\"  visible=
\"false\">
</asp:TextBox>
<asp:TextBox ID=\"txtfirstName\" runat=\"server\" visible=
\"false\">
</asp:TextBox>
</form>
现在假设在第一个复选框上单击,我将具有文本框1的可见性。在第二个复选框上单击,我想取消选中第一个,并将textBox1的可见性设置为false,并使第二个可见。 任何帮助请     

解决方法

        采用
document.getElementById(\"txtLastName\").style.visibility=\"hidden/visible\"
设置可见性和
document.getElementById(\"checkboxId\").checked=true
设置复选框值或与您相同。     ,        我不知道如何在JS中执行此操作,但是我得到了一些jQuery指针。 首先,您在jquery中捕获click事件。然后,选中所有复选框http://api.jquery.com/checkbox-selector/并取消选中它们。然后您使用\“ this \”关键字来检查点击。要使输入可见而我们不可见,可以使用hide / show函数http://api.jquery.com/hide/