檢查複選框是否被 jQuery 選中 - Check if checkbox is checked with jQuery

問題:

How can I check if a checkbox in a checkbox array is checked using the id of the checkbox array?如何使用複選框數組的 id 檢查複選框數組中的複選框是否被選中?

I am using the following code, but it always returns the count of checked checkboxes regardless of id.我正在使用以下代碼,但它始終返回選中複選框的計數,而不管 id。

function isCheckedById(id) {
    alert(id);
    var checked = $("input[@id=" + id + "]:checked").length;
    alert(checked);

    if (checked == 0) {
        return false;
    } else {
        return true;
    }
}

解決方案:

參考一: https://stackoom.com/question/9FQQ
參考二: Check if checkbox is checked with jQuery
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章