how to add id or class to an inserted image
how to add id or class to an inserted image
I have a table:
var table = $('#my-table').DataTable( {
"data" : dataSet,
"bInfo": false,
"bFilter" : false,
paging: false,
"createdRow" : function (row,data,index) {
$('td',row).eq(0).attr('id', 'cost-' + index);
$('td',row).eq(1).attr('id', 'resale-' + index);
deleteImage = $('<img />').attr('src', '../../img/details_close.png');
$('td',row).eq(0).append(deleteImage);
$('td',row).eq(0).addClass( 'icons' );
},
"columns" : [
{ title : 'Cost' },
{ title : 'Resale' },
],
"columnDefs": [
{ className: "details-control", "targets": [ 0 ] }
]
});
It builds fine - but I can't figure out how to add an ID to an image I insert.
I can do:
deleteImage = $('<img />').attr('src', '../../img/details_close.png');
$('td',row).eq(0).append(deleteImage);
to add an image, but I can't seem to add more than one attribute in that same line - only 'src'.