Get element data from a selected row using jquery and select plugin

Get element data from a selected row using jquery and select plugin

itajackassitajackass Posts: 121Questions: 37Answers: 3
edited April 2018 in Free community support

Using this i'd like to show using jquery some values on select using CHECKBOXES. See alert code.

   var table= $('#table').DataTable( {
    dom: 'Bfrtip',
            "columnDefs": [
        {
            orderable: false,
            className: 'select-checkbox',
            targets:   0
        }
    ],
    select: {
        style:    'multi',
        selector: 'td:first-child'
    }
   }).on( 'select', function ( e, dt, type, indexes ) {

        var rowData = table.rows( indexes ).data();

        alert( $(rowData).find(".in").val() );  // <-- doesn't work

        alert( $(rowData).find(".btn").data("content") ); <-- doesn't work

    } );


<table id="table">
  <thead>
<tr> 
 <th/></th>
 <th data-priority="1">Data</th>
<th data-priority="2">Button</th>
   </tr>
  </thead>
 <tbody>
 <tr>
   <td></td>
   <td><input type="text" class="in" value="hello"></td>    
   <td><button type="button" class="btn" data-content="test"></td>   
 </tr>
 </tbody>
</table>

This question has an accepted answers - jump to answer

Answers

  • itajackassitajackass Posts: 121Questions: 37Answers: 3
    Answer ✓

    Ok done using var rowData = table.rows( indexes ).nodes();

This discussion has been closed.