I have been learning some of the more detailed loopholes of JS here and there, and have a few things I need to get help on.
;(function($){
$.fn.makeRed1 = function() {
return $.each(this, function() {
$(this).css('background-color', '#FF0000');
});
}
})(jQuery)
;(function($){
$.fn.makeRed2 = function() {
$(this).css('background-color', '#FF0000');
}
})(jQuery)
Both of these work correctly. Why?
Anyone who talks about writing plugins always says to use the 'return each' method. What is the reason? I need someone to tell me exactly what happens when each of these methods are used, so I can understand the flow.
Thanks.