jQuery判斷checkbox是否選中的3種方法


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

方法二:
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; }


獲取選擇 radio 的值
$("input:radio[name='checkboxName']:checked").val()


 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM