$(document).ready(function() { $('a').filter(function(index) { return this.href == window.location.href; }).addClass('active'); });