jQuery Each

Don’t forget that $(each) and $.each() do two different things in jQuery.

I’ve spent ages before banging my head because a piece of code wasn’t working as expected, and it ended up being because I wrote the wrong version of $.each.

$('selector').each(...) will iterate over the selected elements, while $.each(variable, ...) will iterate over the object/array.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s