Jquery get values of all checked rows in table gridview

后端 未结 5 1247
慢半拍i
慢半拍i 2020-12-15 13:53

I have a table like below


<         
5条回答
  •  春和景丽
    2020-12-15 14:39

    You should do

    $(document).ready(function() {
        var tableControl= document.getElementById('mytable');
       var arrayOfValues = [];
        $('#jqcc').click(function() {
            $('input:checkbox:checked', tableControl).each(function() {
                arrayOfValues.push($(this).closest('tr').find('td:last').text());
            }).get();
        });
    });
    

    arrayOfValues will hold the text inside the last td.

    EDIT of course you could also use map

    $(document).ready(function() {
        var tableControl= document.getElementById('mytable');
       var arrayOfValues = [];
        $('#jqcc').click(function() {
              arrayOfValues =  $('input:checkbox:checked', tableControl).map(function() {
                return $(this).closest('tr').find('td:last').text();
            });
        });
    });
    

提交回复
热议问题
checkedidtext