Skip to content

Instantly share code, notes, and snippets.

@dustinsenos
Created November 13, 2010 21:28
Show Gist options
  • Save dustinsenos/675668 to your computer and use it in GitHub Desktop.
Save dustinsenos/675668 to your computer and use it in GitHub Desktop.
/* Example 1 - Store as variable */
var leftImg = $(images[0]);
var centerImg = $(images[1]);
var rightImg = $(images[2]);
leftImg.css('left', -leftImg.width() + X_OFFSET);
centerImg.css('left', ((windowWidth / 2) - (centerImg.width() / 2)));
rightImg.css('left', windowWidth - X_OFFSET);
/* Example 2 - Lookup */
$(images[0]).css('left', -$(images[0]).width() + X_OFFSET);
$(images[1]).css('left', ((windowWidth / 2) - ($(images[1]).width() / 2)));
$(images[2]).css('left', windowWidth - X_OFFSET);
@dustinsenos
Copy link
Author

Makes sense, I think mixing the two too much could drive your code into some strange patterns with no good cause. I'm incredibly interested in the performance side of JS / jQuery so I appreciate your insight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment