<script>
$(document).ready(function () {
//隱藏SchoolList
$(".schoolist").hide();
//Click收放List
$(".content").on("click",".btn",function () {
$(this).closest(".school").find(".schoolist").fadeToggle();
});
//2
$("#tsch_check0").click(function () {
if ($("#tsch_check0").prop("checked")) {
$("input[name='Tsch[]']").each(function () {
//$(this).prop("check", true)
this.checked = true;
});
}
else {
$("input[name='Tsch[]']").each(function () {
//$(this).prop("checked", false);
this.checked = false;
});
}
});

//$(".btn").click(function () {
// $(this).closest(".school").find(".schoolist").fadeToggle();
//});
});
</script>

 

 

 

 

 

<tr>

<td>&nbsp</td>

<td>

<tableclass="school">

<tr>

<td><inputtype="button"class="btn"value="科大↓">

</tr>

<tr>

<td><tableclass="schoolist"id="tschList">

<tr>

<td><inputtype="checkbox"name="Tsch"id="tsch_check0"value="全選"/>全選</td>

</tr>

<tr>

@foreach (var item in Model) {

<td><inputtype="checkbox"name="Tsch[]"value="@item.學校名稱"/> @item.學校名稱</td>});

</tr>

</table>

</td>

</tr>

 

 

參考資料

1.http://bigone2000.pixnet.net/blog/post/56715490-%E4%BB%A5jquery%E5%AF%A6%E4%BD%9Ccheckbox%E5%85%A8%E9%81%B8%E5%8A%9F%E8%83%BD

2.http://blog.wu-boy.com/2008/12/jquery%E5%88%A4%E6%96%B7-checkbox-%E6%98%AF%E5%90%A6%E9%81%B8%E5%8F%96%EF%BC%8C%E5%AF%A6%E7%8F%BE%E5%85%A8%E9%81%B8%E8%B7%9F%E5%85%A8%E9%83%A8%E5%8F%96%E6%B6%88/

3.https://github.com/yljh21328/code_example/blob/master/JAVASCRIPT/jquery_checkbox.html

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JayeChen987 的頭像
    JayeChen987

    Jaye的碎碎念

    JayeChen987 發表在 痞客邦 留言(0) 人氣()