Revision: 14841
Updated Code
at June 14, 2009 12:54 by 1man
Updated Code
//Save the context in a var
var $main = $("#mainContent");
//If the container exists
if($(".ngg-albumoverview").length){
//Loop through each image, including the index of the object(i)
$(".ngg-album", $main).each(function(i){
//Since 0 based add one, for every 3rd object remainder will equal 0
var remainder = (i + 1) % 3;
//Add a class of last when the remainder is 0
if(remainder === 0){
$(this).addClass("last");
}
});
}
Revision: 14840
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 14, 2009 12:53 by 1man
Initial Code
//Save the context in a var
var $main = $("#mainContent");
//If the container exists
if($(".ngg-albumoverview").length){
//Loop through each image, including the index of the object
$(".ngg-album", $main).each(function(i){
//Since 0 based add one, for every 3rd object remainder will equal 0
var remainder = (i + 1) % 3;
//Add a class of last when the remainder is 0
if(remainder === 0){
$(this).addClass("last");
}
});
}
Initial URL
Initial Description
Quick little clientside script to pick out every 3rd image and add a class of last to it. I needed this because the images were layed out in 3 columns, adding a margin to the right hand side would leave a large gap on the right hand side which i didn't want. This now allows me to remove the margin for the last image.
Initial Title
Add class of 'last' to every 3rd image
Initial Tags
jquery
Initial Language
jQuery