1:判断radio

 

var selected = $('input[name=selectid:checked]').val();//若未被选中 则val() = null
if(selected == null){
alert("未选中!");
}else{
alert("选中!");
}

2:判断checkbox

 

 

var n = $("input:checked").length;
if(n==0){
alert("未选中!");
}else{
alert("选中!");
}
$("div").text(n + (n <= 1 ? " is" : " are") + " checked!");

3:checkbox数组全选、取消全选

$("#selAll").click(function(){
$("input[name='cbox[]']").attr("checked",$(this).attr("checked"));
});
posted on 2010-09-02 15:13  FreeSpider  阅读(3237)  评论(0编辑  收藏  举报