87,993
社区成员
发帖
与我相关
我的任务
分享
<ul id="c1">
@foreach (PQ2014MVC.Models.PQ_Menus item in ViewBag.mli)
{
<li><input type="checkbox" id="ckbox1" name="ckbox2" value="@item.Menu_Id"/>@item.Menu_Name</li>
<ul id="c2">
@foreach (PQ2014MVC.Models.PQ_Menus items in ViewData["p_m"] as List<PQ2014MVC.Models.PQ_Menus>)
{
if(item.Menu_Id==items.Parent_Id)
{
<li><input type="checkbox" id="ckbox2" name="ckbox2" value="@items.Menu_Id" />@items.Menu_Name</li>
}
}
</ul>
}
</ul>
$("input[type='checkbox'][id='ckbox2']").click(function () {
if ($(this).attr("checked") == "checked") {
$(this).parent().parent().parent().find("input[type='checkbox'][id='ckbox1']").attr("checked", true);
}
else {
$(this).parent().parent().parent().find("input[type='checkbox'][id='ckbox1']").attr("checked", false);
}
});

没有人呢??