Home >Web Front-end >HTML Tutorial >How to implement select all checkbox in C# MVC4. _html/css_WEB-ITnose

How to implement select all checkbox in C# MVC4. _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:21:491250browse

mvc4

C# MVC4 How to implement select all checkbox.

Reply to discussion (solution)

        $("#chkAll").click(function () {            if (this.checked) {                $("input[name='chkId']").each(function () { this.checked = true; });            }            else {                $("input[name='chkId']").each(function () { this.checked = false; });            }        });


   <input type="checkbox" id="chkAll" />全选   <input type="checkbox" name="chkId" value="id1" />   <input type="checkbox" name="chkId" value="id2" />

        window.onload = function () {            $("#chkAll").click(function () {                $("input[name='chkId']").attr("checked", this.checked);            });        }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn