I am creating datatable
and adding rows through jQuery
like below. First column in the datatable is radio button.
var hostTable = $('#hostTable').DataTable();
var newRow = "<tr><td><input name='hosts' type='radio' value='-1'/></td><td>test</td><td>test</td><td>test</td></tr>";
hostTable.row.add($(newRow)).draw(false);
On button click, I would like to get name
for the radio button. I have following code, but getting
TypeError: settings.aoColumns[column].attr is not a function
Here is the code:
hostTable.columns().iterator('column', function (settings, column) {
alert(settings.aoColumns[column]);
var tempId = settings.aoColumns[column].attr('name');
alert(tempId);
});
How can I get attr
of a first td
from datatable
? Any help would be appreciated.
Note: I am using latest datatable
, so not using any fn.. functions.
The problem is that .attr() is a jQuery method. Make sure you include this library in your project and try wrapping your element in a jQuery object before calling the function.
var tempId = $(settings.aoColumns[column]).attr('name');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.