I have the following code that I am going through the tables columns and if its the last column I want it to do something different. Right now its hard coded but how can I change so it automatically knows its the last column
$(this).find('td').each(function (i) {
if(i > 0) //this one is fine..first column
{
if(i < 4) // hard coded..I want this to change
{
storageVAR += $(this).find('.'+classTD).val()+',';
}
else
{
storageVAR += $(this).find('.'+classTD).val();
}
}
});
If you want access to the length inside the
.each()callback, then you just need to get the length beforehand so it’s available in your scope.