Skip to content

Instantly share code, notes, and snippets.

@ghorvat
Created August 4, 2015 09:37
Show Gist options
  • Save ghorvat/233def103ded67c2b6d8 to your computer and use it in GitHub Desktop.
Save ghorvat/233def103ded67c2b6d8 to your computer and use it in GitHub Desktop.
<script>
var expTiles = jQuery('[class*="col-"]');
var tmpCount = 0;
var nextIsFirst = false;
var maxInRow = 9;
expTiles.each(function(){
var myColumns;
if(nextIsFirst){
$(this).addClass('first');
nextIsFirst = false;
tmpCount = 0;
}
myColumns = parseInt(this.className.match(/col-test-(\d+)/)[1],10);
tmpCount += myColumns;
console.log(tmpCount);
if(tmpCount >= maxInRow){
nextIsFirst = true;
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment