Skip to content

Instantly share code, notes, and snippets.

@twhite96
Forked from airportyh/example.js
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twhite96/3ccd2082f301e256e5a4 to your computer and use it in GitHub Desktop.
Save twhite96/3ccd2082f301e256e5a4 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'));
});
@twhite96
Copy link
Author

Trying to understand $(this)...

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