本文介绍了动态复选框检查javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好......

我的脚本有问题需要解决。请有人帮帮我..



i有脚本:

hello...
i have problem to solve on my script. somebody help me please..

i have script:

<!DOCTYPE html>
<html>
<head>
    <title>jQuery With Example</title>
    @Scripts.Render("~/bundles/jquery")
    <script type="text/javascript">
        $(function () {

            $('.chkview-1').change(function () {
                $('.chkitem-1').prop('checked', $(this).is(':checked'));
            });

            $(".chkitem-1").change(function () {
                $('.chkview-1').prop('checked', $('.chkitem-1:checked').length == $('.chkitem-1').length);
            });


        });
    </script>
</head>
<body>
    <table id="mytable">
        <tr>
            <td>
                View
            </td>
            <td>Insert</td>
            <td>Update</td>
            <td>Delete</td>
        </tr>
        <tr>
            <td>Administrator</td>
            <td>
                <input type="checkbox" class="chkview-1" />
            </td>
            <td><input type="checkbox" class="chkitem-1"/></td>
            <td><input type="checkbox" class="chkitem-1"/></td>
            <td><input type="checkbox" class="chkitem-1"/></td>
        </tr>
        <tr>
            <td>Free User</td>
            <td>
                <input type="checkbox" class="chkview-2" />
            </td>
            <td><input type="checkbox" class="chkitem-2"/></td>
            <td><input type="checkbox" class="chkitem-2"/></td>
            <td><input type="checkbox" class="chkitem-2"/></td>
        </tr>
    </table>
</body>
</html>





在这种情况下,我会解释我的代码,chkitem-2是chkitem = classid和2动态渲染角色id在一行像管理员所以我创建classid =chkitem-2或chkview- 2.



在此代码中,如果我点击chkview-1所有项目chkitem-1在行管理员中检查为true。我可以动态创建如果我点击chkview-2,所有chkitem-2也在行免费用户中检查为真吗?



有人,请帮帮我..



in this case, i'll explain litle of my code, chkitem-2 is chkitem=classid and 2 dynamically render role id in one row like administrator so i create classid="chkitem-2" or chkview-2.

in this code if i click chkview-1 all item chkitem-1 in row administrator checked true. can i create dynamically if i click chkview-2, all chkitem-2 also checked true in row free user?

somebody, help me please..

推荐答案




这篇关于动态复选框检查javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-22 23:15