document.ready(function(){ $('#table a:visited').each(function(){ $(this.parentNode.parentNode).find(a).addClass('visited'); }); });