Each of them will give you the index of the item in the list. Assuming all of your TH elements belong to a column and you don't have THs elsewhere in the table, you can use this to find the nth-child TD (column) elements of each row and see if any of them contain an input .
jQuery('#' + _target).each(function () {
var $table = jQuery(this);
var i = 0;
jQuery('th', $table).each(function (column) {
if ($('tbody > tr').find('td:nth-child(' + (column+1) + ')')
.has('input')
.length) {
dataTypes[i] = { "sSortDataType": "input" }
}
else {
dataTypes[i] = { "sSortDataType": "html" }
}
i++;
});
});
EDIT : nth-child is unidirectional, while each one is zero based, so I added it to the column variable to take this into account.
source
share