Im trying to create an event for each (a) element in a list (ul). But im doing something wrong
function EnableAjaxOnMenu(ElementID, TagName) {
var elm = jQuery("#" + ElementID).children(TagName).click(function () {
GetPageByUrl(jQuery(this).attr("href"));
//ChangeSelectedMenuItem(this);
return false;
});
}
Does anyone know what im doing wrong here, as far as I can see it won’t even create an event?
If you’re passing the
<ul>ID, then you’ll need.find()instead of.children()to find the<a>elements within, since they’re not direct children, like this:Or, like this: