Javascript to make the current page nav have an active class

$("[href]").each(function() {
    if (this.href == window.location.href) {
        $(this).addClass("active");
        }
});