Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
  <script src="//cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
  <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.2/css/jquery.dataTables.css">
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
  
<style>
body {
  font-family: sans-serif;
}  
</style>
  
<body>
    <table class="datatable" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Office</th>
                <th>Test</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>nixon</td>
                <td>Edinburgh</td>
                <td>0</td>
            </tr>
            <tr>
                <td>garrett</td>
                <td>Tokyo</td>
                <td>0</td>
            </tr>
            <tr>
                <td>ashton</td>
                <td>San Francisco</td>
                <td>0</td>
            </tr>
            <tr>
                <td>kelly</td>
                <td>Edinburgh</td>
                <td>0</td>
            </tr>
            <tr>
                <td>satou</td>
                <td>Tokyo</td>
                <td>0</td>
            </tr>
        </tbody>
    </table>
</body>
</html>
 
var table = $('.datatable').dataTable().api();
var data = [
  {name: 'nixon', value: 1},
  {name: 'satou', value: 1}
];
setTimeout(function () {
  table.rows().data().each(function(value, i) {
    for (var x in data) {
      if (data[x].name === value[0]) {
    
        console.log(i + ' ' + value[0]);
        console.log(i + ' ' + table.cell(i,0).data());
        
        table.cell(i,2).data(data[x].value);
        break;
      }
    }
  });
}, 2000);
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers