Jquery多选、反选、批量

反选栗子:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=GBK">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#select").click(function(){
   $("#table :checkbox").each(function(i,n){
$(this).attr("checked",!$(this).attr("checked"));
       });
  });
});
</script>
</head>
<body>
<div id="table">
<input type="checkbox" name="ids" class="unborder" style="width: 16px;" value="${item.id}">
<input type="checkbox" name="ids" class="unborder" style="width: 16px;" value="${item.id}">
<input type="checkbox" name="ids" class="unborder" style="width: 16px;" value="${item.id}">
<input type="checkbox" name="ids" class="unborder" style="width: 16px;" value="${item.id}">
<input type="checkbox" name="ids" class="unborder" style="width: 16px;" value="${item.id}">
<br>
</div>
<input type="button" id="select" value="反选">


</body></html>

批量:

<input type="button" name="requestCash" id="requestCash" class="btn btn82 btn_add" value="发送">

<a style="padding: 5px;" class="request-cash" href="javascript:;;">发送</a>

$(function() {
	// 批量发送按钮、发送链接
	$('#requestCash,.request-cash').click( function() {
		var ids =[];
		if($(this).hasClass('request-cash')) {	// 发送链接
			ids.push($(this).parents('tr').find('input').val());
		} else {								// 批量发送按钮
			ids = $('input[name=ids]:checked').map( function() { return this.value; });
		}
		if(0 == ids.length) {
			$.messager.alert("提示", "请先选择**再发送!", "info");
			return;
		}
		$.messager.confirm("提示", "是否确认要发送?", function(r) {
			if (!r) { return; }
			load();
			$.post(ctx() + '/cash/requestCash', { ids : Array.prototype.join.call(ids, ',') }, function(data) {
				disLoad();
				if (data.result) {
					$.messager.alert("提示", "保存成功!", "info",searchFormSubmit);
				} else {
					$.messager.alert("提示", data.respMsg, "error",searchFormSubmit);
				}
			}, 'json');
		});
	});




/*$.ajax({url:url,type:'get',dataType:'json',data:$("#transQuery").serialize(),timeout:15000,success:function(data){
		alert(data.respMsg);
	}*/




$(this).attr(key); 获取节点属性名的值,相当于getAttribute(key)方法 

$(this).attr(key, value); 设置节点属性的值,相当于setAttribute(key,value)方法 

$(this).val();获取某个元素节点的value值,相当于$(this).attr(“value”); 

$(this).val(value);设置某个元素节点的value值,相当于$(this).attr(“value”,value); 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值