`
xitonga
  • 浏览: 587464 次
文章分类
社区版块
存档分类
最新评论

jquery实现全选、反选

 
阅读更多


<script src="js/plugin/jquery-1.9.0.js"></script> 


$(document).ready(function() {
	$("#selectAll").click(function() {
		$("input[name='subBox']").each(function() {
			this.checked = true;
		});
	});
	$("#reverse").click(function() {
		$("input[name='subBox']").each(function() {
			if (this.checked) {
				this.checked = false;
			} else {
				this.checked = true;
			}
		});  
	}); 
	$("#checkItems").click(function() {
		$("input[name='subBox']").each(function() {
			if (this.checked) {
				this.checked = false;
			} else {
				this.checked = true;
			}
		});
	});
});

    <td width="15px" align="left"><input type="checkbox" id="checkItems"/></td>        
  				    <td width="35px"><a id="selectAll" name="selectAll" style="cursor: pointer;">全选</a></td> 
  				    <td width="35px"><a id="reverse" name="reverse" style="cursor: pointer;">反选</a></td>  

<td class="check first_child">
				<input type="checkbox" name="subBox" value=""/></span> 
				</td>


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics