How to get column index a td in jquery -
i have table, select rows move column values (from <input>
control) column (also <input>
control). catch here is, columns pre-selected (from data input)
, columns can dynamically arranged (with id's)
i can move values @ moment, have columns hard coded. has data input.
input: colb, cold cola colb colc cold cole 10 20 30 40 50 30 40 50 60 70 50 60 70 80 90 70 80 90 100 110
will require add/append colb
values cold
here's snippet:
var cols = $(row).find("td"); var = parseint($(cols[x]).find("input").val(), 10);
where: x
index of column may dynamic , i'll have search using column id's.
ok! seems you're looking values <input>
elements in given column, given column id. column id ddl, , want array of values column.
so function trick here. here can call getcolumnvalues()
column id ddl, , it'll return array of values column:
function getcolumnvalues(columnid) { var colaindex = $("#" + columnid).index(); var vals = [] $("td:eq(" + colaindex + ")").each(function() { vals.push($(this).val()); } return vals; }
Comments
Post a Comment