$(function(){
//全选反选
$("#checkAll").click(function(){
var ids=document.getElementsByName("id[]")
// alert($(ids).attr("checked"));
$(ids).each(function(){
if($(this).attr("checked")!="checked"){
$(this).attr("checked",true)
}else{
$(this).attr("checked",false)
}
})
})
//全不选
$("#checkNoAll").click(function(){
var ids=document.getElementsByName("id[]")
// alert($(ids).attr("checked"));
$(ids).each(function(){
$(this).attr("checked",false)
})
//获取批量删除值
var ids=$("input:checked");
var idss="";
$(ids).each(function(){
idss+=$(this).val()+',';
});
// alert(idss)
$.get("{url:/test/del}",{"ids":idss},function(msg){
if(msg){
$(ids).each(function(){
$(this).parents("tr").remove()
});
alert("删除成功!")
}else{
alert("删除失败!")
}
})
})
//几点技改
$(document).on("click",".price",function(){
var id=$(this).parent().attr("id");
var val=$(this).html();
// $(this).hide();
$(this).parent().html("<input size='5' class='upda' value='"+val+"'>")
$(".upda").blur(function(){
var va=$(this).val();
var _this=$(this);
$.get("{url:test/upda}",{"id":id,"price":va},function(msg){
if(msg){
_this.parent().html("<span class='price'>"+va+"</span>")
// console.log(t.html())
_this.remove();
alert("修改成功!")
}else{
alert("修改失败!")
}
})
})
})
})
//全选反选
$("#checkAll").click(function(){
var ids=document.getElementsByName("id[]")
// alert($(ids).attr("checked"));
$(ids).each(function(){
if($(this).attr("checked")!="checked"){
$(this).attr("checked",true)
}else{
$(this).attr("checked",false)
}
})
})
//全不选
$("#checkNoAll").click(function(){
var ids=document.getElementsByName("id[]")
// alert($(ids).attr("checked"));
$(ids).each(function(){
$(this).attr("checked",false)
})
})
function checkAll(){ $('input:checkbox').each(function() { $(this).prop('checked', true); }); } function queXiao(){ $('input:checkbox').each(function () { $(this).prop('checked',false); }); }
//批量删除
$("#delAll").click(function(){//获取批量删除值
var ids=$("input:checked");
var idss="";
$(ids).each(function(){
idss+=$(this).val()+',';
});
// alert(idss)
$.get("{url:/test/del}",{"ids":idss},function(msg){
if(msg){
$(ids).each(function(){
$(this).parents("tr").remove()
});
alert("删除成功!")
}else{
alert("删除失败!")
}
})
})
//几点技改
$(document).on("click",".price",function(){
var id=$(this).parent().attr("id");
var val=$(this).html();
// $(this).hide();
$(this).parent().html("<input size='5' class='upda' value='"+val+"'>")
$(".upda").blur(function(){
var va=$(this).val();
var _this=$(this);
$.get("{url:test/upda}",{"id":id,"price":va},function(msg){
if(msg){
_this.parent().html("<span class='price'>"+va+"</span>")
// console.log(t.html())
_this.remove();
alert("修改成功!")
}else{
alert("修改失败!")
}
})
})
})
})