Reputation: 893
Is it possible to assign the value/text of header column to its corresponding data column records using jQuery/JavaScript?
Like id columns should have id header value,and English columns should have English header value etc.
Upvotes: 0
Views: 171
Reputation: 6565
this is your solution:
$(document).ready(function(){
$('tr').find('td').each(function(i){
var ind = $(this).index();
var text = $(this).text();
var header_text = $('thead > tr').find('th:eq('+ind+')').text();
$(this).text(header_text+': '+text);
});
});
Upvotes: 1