Skip to content

Instantly share code, notes, and snippets.

@airportyh
Created May 24, 2015 12:28
Show Gist options
  • Save airportyh/cb9830377272a2d0a816 to your computer and use it in GitHub Desktop.
Save airportyh/cb9830377272a2d0a816 to your computer and use it in GitHub Desktop.
$('a.link').click(function(){
// `this` is an anchor DOM element in this context
// but it's not wrapped in a jQuery wrapper and doesn't
// have access to any of jQuery's helper methods.
var $a = $(this);
// once you wrap it in jQuery, it has access to them,
// for example to `.attr()`, `.prop()`, `.val()`, etc.
console.log('Clicked on', $a.attr('href'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment