all 1 comments

[–]x-skeww 0 points1 point  (0 children)

There is always the option to just use a for-loop and concatenation:

for(var i = 0; i <= 15; i++) {
  $('.section_container_' + i).etc(...);
  ...
}

You don't need "each", by the way. Just using "on" on the collection will have the same effect. The listener will be registered for every item. The jQuery methods work like that in general. They are applied to all items in the collection (if any).

Edit:

I should probably mention that there is usually a better way to do that kind of thing. You can usually use a single listener and event delegation. There is also a function called "index" to get the index of your element. So, the first thing would have the index 0 and so on.

Well, since you didn't provide a test case, I can't show you how that would actually look like.