Contact Us

  • This field is for validation purposes and should be left unchanged.
Heading 1Heading 2Heading 3
row 1 col 1row 1 col 2row 1 col 3
row 2 col 1row 2 col 2row 2 col 3
row 3 col 1row 3 col 2row 3 col 3
<script>
	var headertext = [];
	var headers = document.querySelectorAll("thead");
	var tablebody = document.querySelectorAll("tbody");

	if( headers.length ) {
	
		for (var i = 0; i < headers.length; i++) {
			headertext[i]=[];
			for (var j = 0, headrow; headrow = headers[i].rows[0].cells[j]; j++) {
			  var current = headrow;
			  headertext[i].push(current.textContent);
			  }
		} 

		for (var h = 0, tbody; tbody = tablebody[h]; h++) {
			for (var i = 0, row; row = tbody.rows[i]; i++) {
			  for (var j = 0, col; col = row.cells[j]; j++) {
				col.setAttribute("data-th", headertext[h][j]);
			  } 
			}
		}
	}	
		
</script>

Leave a Reply