I am trying to loop through an array of elements and then validate each instance of each element. This is how I am doing it:
var elements = ["h1","h2","h3","h4","p","strong","label","span","a"];
function targetZWS(){
for (var i = 0; i < elements.length; i++) {
var item = $(".page-content "+elements[i]);
$(item).each(function() {
checkElement(this);
});
}
}
This throws a warning that I am creating a function inside a loop, how do I avoid this?
checkElementsfunction that loops over all of your items and calling it from inside the loop still cause a warning?$(".page-content").find(elements.join(',')).each(...). Or changecheckElementto accept an index as first argument and the element as second argument and useitem.each(checkElement). Or both.