码迷,mamicode.com
首页 > 其他好文 > 详细

批删,全选

时间:2017-01-30 22:50:42      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:cli   his   echo   状态   txt   style   type   rem   name   

<th>全选<input type="checkbox" onclick="all_()" class="che_"></th>
<td><input type="checkbox" name="check_" value="<?php echo $v[‘w_id‘] ?>"></td>
function dels() //批删
{
var w_id = ‘‘;
$(‘input[name=check_]‘).each(function () {
if ($(this).is(‘:checked‘)) {
w_id += ‘,‘ + $(this).val();
}
});
if(w_id==‘‘){
alert(‘还没有选中呢‘);
}else{
if (confirm(‘确认删除吗?‘)) {
$.ajax({
url: ‘index.php?r=hshuo/dels‘,
data: {id: w_id.substr(1)},
// datatype:‘json‘,
type: ‘post‘,
success: function (txt) {
if (txt > 0) {
$(‘input[name=check_]‘).each(function(){
if($(this).is(‘:checked‘)){
$(this).parent().parent().remove(); //删除节点
}
});
$(‘.che_‘).prop(‘checked‘,false); //把全选变成不选中的状态

alert(‘删除成功‘);
} else {
alert(‘删除失败‘)
}
}
})
}
}
}
function all_() //全选
{
if($(‘.che_‘).is(‘:checked‘)){
$(‘input[name=check_]‘).prop(‘checked‘,true);
}else {
$(‘input[name=check_]‘).prop(‘checked‘,false);
}
}

批删,全选

标签:cli   his   echo   状态   txt   style   type   rem   name   

原文地址:http://www.cnblogs.com/taikongliu/p/6358438.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!