Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created July 12, 2010 17:36
Show Gist options
  • Save cowboy/472783 to your computer and use it in GitHub Desktop.
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 ] );
}
});
};