-1

I have the following code:

 $("input:checkbox").click(function () {
getIndex($(this).attr("value").index(this));
}

The value of the check box and table header text match. When I click on the cb, I want to get the column index of the table column that corresponds to the cb text and then pass it to getIndex. How do I go about it?

So let us say the checkbox value is "Col1". There is a table column header with the same value "Col1". Similarly "Col2", Col3 and so on. When I click on a cb called "Col3", I want to find the corresponding table column index with the cb text that matches the column header text.

4

1 回答 1

0

尝试这个:

function getColumnIndexesByValue(value) {
  return $('col[value="' + value + '"]').map(function() {
    return $(this).index() + 1;
  }).get();
}
于 2012-10-11T14:54:09.887 回答