Skip to content

Instantly share code, notes, and snippets.

@fnhipster
Created August 26, 2011 19:53
Show Gist options
  • Save fnhipster/1174272 to your computer and use it in GitHub Desktop.
Save fnhipster/1174272 to your computer and use it in GitHub Desktop.
Get boxes in the last column and row of a table of 3 columns
// Making fancy borders on the product listing page.
var total = $(".ProductList li").length;
var last_row = Math.ceil(total/3);
var n;
var current_row;
$(".ProductList li").each(function(i){
n = i+1;
current_row = Math.ceil(n/3);
// Get boxes in the last column.
if( n%3 == 0 ){
$(this).css("border-right","0 none");
}
// Get boxes in the last row
if( current_row == last_row ){
$(this).css("border-bottom","0 none");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment