Use jQuery to match current URL to herf in a UL and add class if matched
<p>I have a dynamically created UL. I want to use jQuery to use the current URL, search through a specified UL and find any li with a matching href. If one is found then add the class "current_page".</p>

<p>I came up with this but it doesn't seem to do the trick.</p>

<pre><code>$(document).ready(function() {  
    $("ul.nav_cat_archiveli").find("a[href='"+window.location.pathname+"']").each(function() {
        $(this).addClass("current_page");
    });
});
</code></pre>
