JavaScript
Article

jQuery .each() skip to next one

By Sam Deering

Workaround jQuery code snippet to skip next interation in a loop. Just documenting this code snippet, no demo sorry.

//output keys=values. eg [1]=[2], [3]=[4] etc, skips undefined keys
var i = 0;
$.each(array, function(key, val)
{
	if (webTrendsParams[i]) {
		console.log(array[i] + ' = ' + array[i+1]);
	}
	i = i + 2;
});

No Reader comments

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in JavaScript, once a week, for free.