Shorter $.each
In most cases when you are going to use $.each method you just want to call simple function on each element of the set.
In such cases instead of:
$('.nice-class').each(function(index, Element) {
Element.doSmth();
});
You can just write:
$('.nice-class').each(doSmth);
Examples?
var hide_it = function() { $(this).hide(); };
$('[data-hidden]').each(hide_it);
Written by Jan Dudulski
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Each
Authors
jandudulski
1.473K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#