Reputation: 75
I want to select all rows in a table but exclude some columns, it is also not possible to assign classnames in this case.
what i have now is this:
http://jsbin.com/ibulej/5/edit
which works for one column.
I will use that later for a inline-table search for different tables, where i have to exclude some columns.
whats the best way to accomplish this task?
Upvotes: 0
Views: 213
Reputation: 13461
You can use the following code to exclude columns from selection which uses a combination of $.filter
and $.index
to accomplish the task
var cols = [2,3,4];
$("#button").click(function() {
var jo = $("#tableid tr").find('td').filter(function(i){
if($.inArray($(this).index()+1,cols) != -1)
return false;
else
return true;
});
jo.css("background-color","red");
});
Build your exclude list in cols
array and those will be excluded from selection.
I am not sure if this is the best way, but it works for what you need.
Upvotes: 1