I have dynamically created UL. I want to use jQuery to use the current URL, search on the specified UL, and search for any with the appropriate href. If it is found, add the class "current_page".
I came up with this, but it doesn't seem to be the trick.
$(document).ready(function() {
$("ul.nav_cat_archiveli").find("a[href='"+window.location.pathname+"']").each(function() {
$(this).addClass("current_page");
});
});
source
share