反选栗子:
<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);