试了下,没发现问题<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#setAll").click(function () {
$(":checkbox[name=playList]").attr("checked", true);
}); $("#unSetAll").click(function () {
$(":checkbox[name=playList]").attr("checked", false);
}); $("#reverse").click(function () {
$(":checkbox[name=playList]").each(function () {
$(this).attr("checked", !$(this).attr("checked"));
});
});
}); </script>
</head><body>
<input type="checkbox" name="playList" />歌曲1<br />
<input type="checkbox" name="playList" />歌曲2<br />
<input type="checkbox" name="playList" />歌曲3<br />
<input type="checkbox" name="playList" />歌曲4<br />
<input type="checkbox" name="playList" />歌曲5<br />
<input type="checkbox" name="playList" />歌曲6<br />
<input type="button" id="setAll" value="全选"/>
<input type="button" id="unSetAll" value="全不选"/>
<input type="button" id="reverse" value="反选"/>
</body>
</html>
<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#setAll").click(function () {
$(":checkbox[name=playList]").attr("checked", true);
}); $("#unSetAll").click(function () {
$(":checkbox[name=playList]").attr("checked", false);
}); $("#reverse").click(function () {
$(":checkbox[name=playList]").each(function () {
$(this).attr("checked", !$(this).attr("checked"));
});
});
}); </script>
</head><body>
<input type="checkbox" name="playList" />歌曲1<br />
<input type="checkbox" name="playList" />歌曲2<br />
<input type="checkbox" name="playList" />歌曲3<br />
<input type="checkbox" name="playList" />歌曲4<br />
<input type="checkbox" name="playList" />歌曲5<br />
<input type="checkbox" name="playList" />歌曲6<br />
<input type="button" id="setAll" value="全选"/>
<input type="button" id="unSetAll" value="全不选"/>
<input type="button" id="reverse" value="反选"/>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货