jQuery select row based on another table row index
I have 2 tables. One holds only first column of my "data table" rest is stored in another table, that is placed right to first.
What I need to do is to get all the data from specific row to pass it to jqplot.
My tables look like this: http://jsfiddle.net/Misiu/eajpy/1/
My code basically works, but I think it can be improved. Any advice will be helpful :)
My code looks like this:
$('table#baseTable > tbody > tr > td').click(function() {
var rowIndex = $(this).parent().index();
$('div#log').html(rowIndex);
var myData = [];
$('#dataTable tbody tr:eq(' + rowIndex + ')').map(function() {
return $(this.cells).get();
}).each(function() {
var headerVal = $(this).closest("table").find("thead > tr > th").eq($(this).index()).html();
myData.push([headerVal, $(this).html()]);
})
alert(myData);
console.log(myData);
});
Misiu
- 349
- 1
- 5
- 15
default