checkbox全选

来源:互联网 发布:linux 回到根目录 编辑:程序博客网 时间:2024/05/19 11:45

//全选js方法;

<script type="text/javascript">

// $(window).ready()这个方法是当前看到的网页;

    $(window).ready(function () {
        var status = true;
        $("#all").click(function () {
            if (status) {
                $("input[type=checkbox]").each(function () {
                    $(this).attr("checked", "checked");
                });
                status = false;
            } else {
                $("input[type=checkbox]").each(function () {
                    $(this).removeAttr("checked");
                });
                status = true;
            }
        });
    });
</script>

//全选按钮

<td class="left01" width="40">
                        <div align="center">
                        <span><a href="javascript:void(0)" class="s3" id="all">全选</a></span></div>
</td>

0 0
原创粉丝点击