How to find out whether the check box is checked or not checked?

This question already has an answer here:

  • How to check whether a checkbox is checked in jQuery? 56 answers

  • 我不太熟悉jQuery,但试试这个:

    var values = [];
    $('input[name="transport"]').each(function () {
        if ( $(this).is(':checked') ) {
            values.push( $(this).attr('value') );
        }
    });
    
    alert(values);
    

    尝试这个:

    $('#bike').is(':checked');
    

    $(':checkbox[name=transport]:checked').each(function (i, ele) {
        var value = $(ele).val();
        console.log(value); 
    });
    
    链接地址: http://www.djcxy.com/p/9524.html

    上一篇: 根据复选框显示/隐藏输入栏

    下一篇: 如何确定复选框是否已选中或未选中?