【发布时间】:2021-01-22 12:35:27
【问题描述】:
我有一个问题,我需要创建一个全选复选框,该复选框已经 100% 运行,但我无法创建仅标记其子复选框的“父”复选框
enter code here
<input type="checkbox" title="todos" id="checkTodos" name="checkTodos"> <label><b>Marcar/Desmarcar Todos</b></label>
<div class="Registro">
<input type="checkbox" checked="checked" class="chkTela" />
<asp:HyperLink runat="server" ID="hlTela">
<span class="Tela">Tela <%#Eval("Descricao") %></span></asp:HyperLink>
<ul>
<asp:Repeater ID="rptTipoCritica" runat="server" OnItemCommand="rptTipoCriticas_ItemCommand">
<ItemTemplate>
<li>
<input name="chkCritica" id='chk<%#Eval("Codigo") %>' value='<%#Eval("Codigo") %>' type="checkbox" <%# EmAnalise && (Eval("Executada").ToString() == "False") ? "checked='checked' ": "disabled=disabled" %> />
<asp:Image ID="imgExecutada" runat="server" />
<asp:Button ID="btnVerificar" runat="server" Text="Verificar" CommandArgument='<%#Eval("Codigo") %>' CommandName="Verificar" />
<label for='chk<%#Eval("Codigo") %>'><%#Eval("Descricao") %></label></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
<script type="text/javascript">
$(function() {
$(".chkTela").on("click",
function() {
propagarSelecao($(this));
});
});
$("#checkTodos").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
function propagarSelecao($chk) {
$("input[type=checkbox]:not(:disabled)", $chk.parent()).attr("checked", $chk.attr("checked"));
}
</script>
【问题讨论】:
-
我是否正确理解您的问题:如果选择了父母,您想选择所有孩子吗?!
-
@AbbasAkhundov 完全正确,我的复选框 100% 正常工作,但我需要复选框“爸爸”
标签: javascript c#