Array.prototype.forEach.call(document.querySelectorAll('a.hostip'), function(a){ var text = a.innerHTML; if(text.length > 15){ a.innerHTML = text.slice(0, 15) + '...' } });