@@ -75,8 +75,8 @@ In addition, the primary purpose of an Immediately Invoked Function is to allow
75
75
76
76
Your typical jQuery object will contain references to any number of DOM
77
77
elements, and that's why jQuery objects are often referred to as collections.
78
- If you want to do any manipulating with specific elements (eg: getting an
79
- attribute, individualy calculated positions) then you need to use ` each() ` to
78
+ If you want to do any manipulating with specific elements (eg: getting data an
79
+ attribute, calculating specific positions) then you need to use ` each() ` to
80
80
loop through the elements.
81
81
82
82
<javascript >
@@ -89,7 +89,7 @@ $.fn.myNewPlugin = function() {
89
89
90
90
Notice that we return the results of ` each() ` instead of returning ` this ` .
91
91
Since ` each() ` is already chainable, it returns ` this ` , which we then return.
92
- This is a better way to write plugins than what we've been doing so far.
92
+ This is a better way to maintain chainability than what we've been doing so far.
93
93
94
94
##Putting it together
95
95
@@ -137,20 +137,3 @@ return value of that callback will determine what is appended to each element
137
137
in the collection. Notice also that we're not using the ` attr ` method to
138
138
retrieve the href attribute, because the native DOM API gives us easy access
139
139
with the aptly named href property.
140
-
141
- Here's another example of a plugin. This one doesn't require us to loop
142
- through every element with the ` each() ` method. Instead, we're simply going to
143
- delegate to other jQuery methods directly:
144
-
145
- <javascript >
146
- (function($){
147
- $.fn.fadeInAndAddClass = function(duration, className) {
148
- return this.fadeIn(duration, function(){
149
- $(this).addClass(className);
150
- });
151
- };
152
- }(jQuery));
153
-
154
- // Usage example:
155
- $('a').fadeInAndAddClass(400, 'finishedFading');
156
- </javascript >
0 commit comments