Created
May 28, 2015 10:56
-
-
Save steve10287/6c2510b1a82f7a45e9ba to your computer and use it in GitHub Desktop.
Convert Table to Responsive Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
Convert finance tables into responsive tables | |
Loop thru each table header or in this cast tr:first child | |
Then add the title for the table header to the the td elements as a data attribute | |
Then in css: use :before {content: attr(data-content)} | |
***/ | |
$('table.finance').each(function() | |
{ | |
var nthChild = 1; | |
$(this).find('tbody > tr:first-child > td').each(function(e) | |
{ | |
var title = this.innerText; | |
$(this).parent().parent().parent().find('tbody tr:not(:first-child) td:nth-child(' + nthChild + ')').attr('data-content', title); | |
nthChild++ | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment