jquery loop through elements add to array
I am trying to loop through an array. I have the following codeResources. MDN loops and iterators. No need for jquery here just a for loop worksThats a tiny bit of added overhead per loop iteration on most arrays, but if you have a sparse array, it can be a more efficient way to loop This throws a warning that I am creating a function inside a loop, how do I avoid this? You are trying too hard :) JQuery allows you to enter multiple options in a singleUse .each() to loop through the array as: (function() var elements ["h1","h2","h3","h4","p","strong","label","span","a"] .each( elements And then loop over like: (input[namedt]).each(function() // code alert( this.