Created
February 22, 2011 09:42
-
-
Save micha149/838423 to your computer and use it in GitHub Desktop.
Adding classes to first and last columns via jQuery
This file contains 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
for (var i = 0; i < teaserData.length; i++) { | |
// Create teaser markup | |
var teaser = $('<div/>').addClass('teaser'); | |
// ... | |
// Constructing the teaser | |
// ... | |
teaser.appendTo(container); | |
// Marks the first and last column by a 3 column layout | |
if (teaser.is(':nth-child(3n-2)')) { | |
teaser.addClass('firstColumn'); | |
} else if (teaser.is(':nth-child(3n)')) { | |
teaser.addClass('lastColumn'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment