Skip to content

Instantly share code, notes, and snippets.

@JeffreyWay
Created October 7, 2011 15:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffreyWay/1270649 to your computer and use it in GitHub Desktop.
Save JeffreyWay/1270649 to your computer and use it in GitHub Desktop.
// Bad
$('a').click(function() {
$(this).hide();
$(this).css('color', 'red');
$(this).show();
alert('something else');
$(this).hide();
});
// Better
$('a').click(function() {
var anchor = $(this);
anchor.hide().css('color', 'red').show();
alert('something else');
anchor.hide();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment