显示隐藏复选框和标签 [英] Show Hide Checkbox and label
问题描述
大家好,
我有一个.ascx(controller)和一个javascript文件.
场景:
当我单击复选框时,它必须显示和隐藏其他复选框,不仅是复选框,而且还有标签.事实是,现在我成功地使其仅隐藏了该复选框.而且我也需要隐藏标签.
这是来自ascx文件的原始代码:
Hello everyone,
I have an .ascx(controller) and a javascript files.
THE SCENARIO:
When i click the checkbox it must show and hide other checkbox, and not only the checkbox but the label too. The fact is now i succeed to make it hide just the checkbox. And i need to make hide the label too.
here is the raw code from ascx file:
<ItemTemplate>
<li class="area">
<input type="checkbox" class="category" value="<%# string.Concat(CurrentLocation.Area1,"| ", CurrentLocation.Area2)%>" />
<label>
<%#CurrentLocation.Area2%>
</label>
<asp:Repeater ID="Repeater2" runat="server" DataSource="<%# GetThirdAreas(CurrentLocation.Area2) %>">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<input type="checkbox" class="category" value="<%#string.Concat(CurrentLocation.Area1,"| ", CurrentLocation.Area2,"| ", CurrentLocation.Area3)%>" />
<label>
<%#CurrentLocation.Area3%>
</label>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
这是javascript文件:
And here is the javascript file:
function updateByArea(current) {
//If current is unchecked => uncheck all child checkboxes
if (current.attr("checked") == null || current.attr("checked") == "")
$j(".area ul li input [value^='" + current.val() + "']:checked").removeAttr("checked").hide(); //checkbox
$j("#searchFilter .area>input:checkbox:checked").each(function (i, item) {
$j(".area ul li input[value^='" + $j(item).val() + "']:not(:checked)").attr("checked", "checked").show();//checkbox
});
}
问题:
我如何将标签添加到javascript代码中,以便当用户单击checkbiox并隐藏复选框时也隐藏标签?
在此先谢谢您
THE QUESTION:
how i add the label to javascript code so when the user clicks the checkbiox and hides the checkbox to hide the label too?
Thank you in advance
推荐答案
j(" + current.val()+ ']:已选中" ).removeAttr(" ).hide(); // 复选框
j(".area ul li input [value^='" + current.val() + "']:checked").removeAttr("checked").hide(); //checkbox
j( #searchFilter .area> input:checkbox:checked").each(
j("#searchFilter .area>input:checkbox:checked").each(function (i, item) {
j(" +
这篇关于显示隐藏复选框和标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!