I'm trying to add a class name to dynatable generated <td>
s, but I don't know how. I've tried this, but does not work:
<table id="my-final-table">
<thead>
<th>Band</th>
<th>Song</th>
<th style="display:none;" class="td-id">id</th>
</thead>
<tbody>
</tbody>
</table>
I want to add td-id
to the last <td>
.
var jsondata=[
{
"band": "Weezer",
"song": "El Scorcho",
"id":1
},
{
"band": "Chevelle",
"song": "Family System",
"id":2
}
];
var processingComplete = function(){
$('#my-final-table tr').on("click",function(){
console.log($(this));
});
};
$('#my-final-table').dynatable({
dataset: {
records: jsondata
}
}).bind('dynatable:afterProcess', processingComplete);
processingComplete();
But the row html
is like this when I click on a row:
<td style="text-align: center;">Chevelle</td>
<td style="text-align: center;">Family System</td>
<td style="display: none;text-align: start;">2</td>
JSFiddle: http://jsfiddle.net/maysamsh/pDVvx/5/
You could do something like this -
$('tr').each(function(){
$(this).find('td').eq(1).addClass('yellow');
})