Jquery 实现checkbox全选方法

2020-05-23 06:09:12易采站长站整理

        });
    });
});

页面使用


<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
    <title></title>
</head>
<body>
    <script src=”http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js” type=”text/javascript”>
    </script>
    <script src=”xs_checkbox_all.js” type=”text/javascript”></script>
    <fieldset>
        <legend>全选one</legend>
        <input type=”checkbox” class=”xsChk” name=”chk” />
        全选
    <div>
        <input type=”checkbox” name=”chk” />
        1<br />
        <input type=”checkbox” name=”chk” />
        2<br />
        <input type=”checkbox” name=”chk” />
        3<br />
        <input type=”checkbox” name=”chk” />
        4<br />
    </div>
    </fieldset>
    <fieldset>
        <legend>全选two</legend>
        <input type=”checkbox” class=”xsChk” name=”chk1″ />
        全选2
    <div>
        <input type=”checkbox” name=”chk1″ />
        11<br />
        <input type=”checkbox” name=”chk1″ />
        22<br />
        <input type=”checkbox” name=”chk1″ />
        33<br />
        <input type=”checkbox” name=”chk1″ />
        44<br />
    </div>
    </fieldset>