$("#allCheck").change(function(){
var flag = $(this).attr("checked");
$('#delForm input[type="checkbox"]').each(function () {
$(this).attr('checked',flag)})
});
2 jsp中:
var flag = $(this).attr("checked");
$('#delForm input[type="checkbox"]').each(function () {
$(this).attr('checked',flag)})
});
2 jsp中:
<th scope="col" class="borl_no"><input id="allCheck" type="checkbox" name="" value="" /></th>
3 有時(shí)候在頁(yè)面中有多處checkbox,所以根據(jù)id來(lái)區(qū)別,這時(shí)需要根據(jù)id來(lái)控制全選的區(qū)域:
4 是否選擇checkbox判斷:
3 有時(shí)候在頁(yè)面中有多處checkbox,所以根據(jù)id來(lái)區(qū)別,這時(shí)需要根據(jù)id來(lái)控制全選的區(qū)域:
$('#checkid').click(function(){
var list = $('[id=check]').length;
if($('#checkid').attr("checked")==true){
for(var i = 0 ; i < list ; i ++){
$('[id=check]').attr("checked","true");
}
}else if($('#checkid').attr("checked")==false){
$('[id=check]').click();
}
});
var list = $('[id=check]').length;
if($('#checkid').attr("checked")==true){
for(var i = 0 ; i < list ; i ++){
$('[id=check]').attr("checked","true");
}
}else if($('#checkid').attr("checked")==false){
$('[id=check]').click();
}
});
等同于
$("#checkid").change(function(){
var flag = $(this).attr("checked");
$('[id=check]').each(function () {
$(this).attr('checked',flag)})
});
$("#checkid").change(function(){
var flag = $(this).attr("checked");
$('[id=check]').each(function () {
$(this).attr('checked',flag)})
});
4 是否選擇checkbox判斷:
function del(){
var num=0;
$('input[type="checkbox"]').each(function () {
if ($(this).attr('checked')) {
num++;
}
});
if(num==0){
alert("請(qǐng)選擇刪除對(duì)象!");
return;
}
if(confirm("您確定要?jiǎng)h除選中的項(xiàng)目么?")){
document.getElementById("delForm").action="/html/com/deleteCallMarketContactAction.do";
document.getElementById("delForm").submit();
}
}
var num=0;
$('input[type="checkbox"]').each(function () {
if ($(this).attr('checked')) {
num++;
}
});
if(num==0){
alert("請(qǐng)選擇刪除對(duì)象!");
return;
}
if(confirm("您確定要?jiǎng)h除選中的項(xiàng)目么?")){
document.getElementById("delForm").action="/html/com/deleteCallMarketContactAction.do";
document.getElementById("delForm").submit();
}
}