A couple questions:
Is a regular javascript loop (to loop through a series of elements) faster/more efficient than using jQuery
each()
??If so, what is the best way to write the following code as a regular javascript loop?
$('div').each(function(){ //... })
for
loop is faster, but note that if what you're doing within the loop involves callback functions that need to use the loop index variable later then you would need to introduce a closure and that would (more or less) cancel out the efficiency gains. – nnnnnn Aug 24 '12 at 21:54