Skip to content

Instantly share code, notes, and snippets.

@imehr
Created March 24, 2013 01:12
Show Gist options
  • Save imehr/5230000 to your computer and use it in GitHub Desktop.
Save imehr/5230000 to your computer and use it in GitHub Desktop.
javasctipt: #table, #clone-header
$(document).ready(function() {
TABLE.repeatHeader('#celebs', 10)
});
var TABLE = {};
TABLE.repeatHeader = function(table, every){
$(table).each(function() {
var $this = $(this);
var rowsLen = $this.find('tr:not(:first)').length;
$(this).find('tr:first')
.clone()
.insertAfter($this.find('tr:nth-child(' + every + 'n)'));
if((rowsLen) % every === 0 ) {
$this.find('tr:last').remove();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment