Getting values of selected table rows in bootstrap using jquery

前端 未结 4 637
一生所求
一生所求 2020-12-08 05:46

I\'m using bootstrap table. In that I want to get Item ID value/values of selected table rows after clicking \'Add to cart\' button present on same

4条回答
  •  孤城傲影
    2020-12-08 06:20

    Here is example give it to you :

    HTML

    Item ID
    5
    15
    10

    JS

    var arr;
    $('button').click(function(){
      arr = $('#table-style').find('[type="checkbox"]:checked').map(function(){
          return $(this).closest('tr').find('td:nth-child(2)').text();
      }).get();
    
      console.log(arr);
    });
    

    DEMO

提交回复
热议问题