Created
June 11, 2015 10:25
-
-
Save steve10287/d93a9f4aa12533d26ca1 to your computer and use it in GitHub Desktop.
responsivetable
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').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