$(document).ready(function() { var url=document.location.href; $.each($("div.menu a"),function(e){ if(url==this.href){$(this).addClass('active');}; }); });