Skip to content

Instantly share code, notes, and snippets.

@bspingarn
Created April 12, 2012 19:23
Show Gist options
  • Save bspingarn/2370313 to your computer and use it in GitHub Desktop.
Save bspingarn/2370313 to your computer and use it in GitHub Desktop.
Shorten each link text of a class name on pageload
function shortenLink(){
var screenWidth = $(window).width();
var f = function(){
var linkTextURL = $(this).text();
if (screenWidth < 450) linkTextURL = linkTextURL.substring(0,40) + "...";
$(this).text(linkTextURL);
}
$('a.resultLink').each(f);
}
$(function(){ //page load
shortenLink();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment