$('DIV.top_menu A').each(function () { var re = new RegExp('^' + this.href); if(re.test(document.location.pathname)) { this.parentNode.className = "current"; } });