$(document).ready(function() { if(location.href.indexOf("/taxonomy/term/") != -1) { $('#main a').each(function() { if($(this).attr('href') && $(this).attr('href').indexOf('.pdf') != -1 && $(this).html().indexOf('<') == -1) { var text = $(this).text(); if(text.length > 20) { if(text.indexOf('/') != -1) { text = text.substring(text.lastIndexOf('/') +1); } if(text.length > 20) { text = text.substring(0, 17) + '...pdf'; } $(this).html(text); if($(this).css('display') == 'none') { $(this).css('display', 'block'); } } } }); } });