Created
July 12, 2010 17:36
-
-
Save cowboy/472783 to your computer and use it in GitHub Desktop.
jQuery Pluginization (see comment for slide order)
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
function longUrl( elem ) { | |
var href = elem.attr( 'href' ), | |
api = 'http://www.longurlplease.com/api/v1.1?callback=?'; | |
// Fetch JSON data. | |
jQuery.getJSON( api, { q: href }, function(data){ | |
if ( data[ href ] ) { | |
// Update the element's title attribute. | |
elem.attr( 'title', data[ href ] ); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here are the general steps, in-order: