Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created July 12, 2010 17:36
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cowboy/472783 to your computer and use it in GitHub Desktop.
jQuery Pluginization (see comment for slide order)
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 ] );
}
});
};