检查复选框是否被 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章