input checkbox操做,最好用prop,不要用attr

方法一:
1 if ($("#checkbox-id").get(0).checked) {
2 // do something
3 }
 
 

 



方法二:
if($('#checkbox-id').is(':checked')) {
// do something
}
 
 
方法三:
if ($('#checkbox-id').attr('checked')) {
// do something
}
 
 

在jQuery1.6版本以後,取複選框有沒有被選中,要用prop
if($('#checkbox-id').prop('checked'))
{
  //do something
}
function checkInfo(){
$("input[name='org3.otherValues']").each(
function(){
if($(this).get(0).checked){
return true;
}
});
var org3_ids=$("#org3_ids").val();
if(org3_ids!=''){
return true;
}

alertMsg.warn("請選擇接收人!");
return false;
}
相關文章
相關標籤/搜索