<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
  <body>
    <button type="button" id="ajaxLoad">Load Data!</button>
    <div class="container">
      <table id="example" class="display table-striped compact nowrap" style="width:100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tbody>
             <tr>
                <td>Name</td>
                <td>Position</td>
                <td>Office</td>
                <td>Extn.</td>
                <td>Start date</td>
                <td>Salary</td>
            </tr>
          <tr>
                <td>Name</td>
                <td>Position</td>
                <td>Office</td>
                <td>Extn.</td>
                <td>Start date</td>
                <td>Salary</td>
            </tr>
          <tr>
                <td>Name</td>
                <td>Position</td>
                <td>Office</td>
                <td>Extn.</td>
                <td>Start date</td>
                <td>Salary</td>
            </tr>
          <tr>
                <td>Name</td>
                <td>Position</td>
                <td>Office</td>
                <td>Extn.</td>
                <td>Start date</td>
                <td>Salary</td>
            </tr>
          <tr>
                <td>Name</td>
                <td>Position</td>
                <td>Office</td>
                <td>Extn.</td>
                <td>Start date</td>
                <td>Salary</td>
            </tr>
        </tbody>
        
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
    </table>
    </div>
  </body>
</html>
 
body {
  font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  color: #333;
  background-color:white;
}
table.dataTable tbody tr.myeven{
    background-color:#f2dede;
}
table.dataTable tbody tr.myodd{
    background-color:#bce8f1;
}
 
$('#example').dataTable({
        "rowCallback": function( row, data, index ) {
            if(index%2 == 0){
                $(row).removeClass('myodd myeven');
                $(row).addClass('myodd');
            }else{
                $(row).removeClass('myodd myeven');
                 $(row).addClass('myeven');
            }
          }
    });
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers