JSFiddle - React, Tailwind, and code Playground

by rotailed

HTML

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
<script src="https://cdn.datatables.net/select/1.2.0/js/dataTables.select.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.2.0/css/select.dataTables.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.2.2/css/buttons.dataTables.css">
<link rel="stylesheet" href="https://nightly.datatables.net/css/jquery.dataTables.css">
<div id="result">
</div>
<table id="example" class="table" width="100%">
        <thead>
          <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        </thead>

        <tfoot>
          <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        </tfoot>

        <tbody>
          <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$3,120</td>
          </tr>
          <tr>
            <td>Garrett Winters</td>
            <td>Director</td>
            <td>Edinburgh</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$5,300</td>
          </tr>
          <tr>
            <td>Ashton Cox</td>
            <td>Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$4,800</td>
          </tr>
          <tr>
            <td>Cedric Kelly</td>
            <td>Javascript Developer</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2012/03/29</td>
  ...

JavaScript

$(document).ready(function() {
    
	    var table = $('#example').DataTable( {
	        dom: 'Bfrtip',
	        select: true,
	        buttons: [
	            {
	                text: 'Modify selected user age',
 					action: function ( e, dt, button, config ) {
 						console.log('ici');
						var data 			= dt.row( { selected: true } ).data();
						var actualUser 		= (data[Object.keys(data)[0]]);
						var actualAge 		= (data[Object.keys(data)[3]]);
						var newAge			= Number(actualAge) + 1;
						if (confirm('Modify ' +  actualUser + ' age\'s to ' + newAge+ ' ?')) {
							 $("#result").text('updated to ' + newAge);
							  
				    	}
	                }
	            }
	        ]
	    } );
	} );