您的位置:首页 > Web前端 > JQuery

Jquery中全选和反选的做法

2009-10-28 08:39 127 查看
<script type="text/javascript" src="js/jquery.js"/>
<script type="text/javascript">
<!--
$(function() {
$("#selectall").click(function() {
$("input[name='chk']").each(function() {
$(this).attr("checked", true);
});
});
$("#deselectall").click(function() {
$("input[name='chk']").each(function() {
$(this).attr("checked", false);
});
});
});
// -->
</script>


<body>
<input type='checkbox' id='in-shareuser-10' name='chk' value='10' />唱歌
<input type='checkbox' id='in-shareuser-11' name='chk' value='11' />跳舞
<input type='checkbox' id='in-shareuser-12' name='chk' value='12' />美术

<input type="button" id="selectall" name="selectall" value="全选" />
<input type="button" id="deselectall" name="deselectall" value="取消全选" />
</body>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: