$('a').each(function() {
        if(document.URL.indexOf($(this).attr('href')) >= 0) $(this).addClass('selected');   
});

Note: This code will add the 'selected' css class to all <a> tags which link to the current page.

Leave a Reply

Your email address will not be published. Required fields are marked *