$('.list-links-nested a').each(function(){
currentPage(this);
});
$("#menu-main > li > a").each(function(){
currentPage(this);
});
$("#menu-sub a").each(function(){
currentPage(this);
});
Any suggestion on how to write it better instead of repeating the function called?
Updated code and it works:
var links = $(".list-links-nested a, #menu-main > li > a");
links.each(currentPage);
You can use a comma in your string to provide multiple selectors.
You can also pass
currentPageas an argument itself and usethisdirectly, instead of the argument you were passing.