(^506) ❘ APPENDIX C SELECTING, TRAVERSING, AND FILTERING
bapp03.indd 02/17/2015 Page 506
map(function(index,
element))
Like each(), each matched element is passed
into a callback function. The return value of
each callback function is used to build a new
jQuery object, creating a mapping to a new
array of element references. Returning the
item or array of items includes it in the new
array. Returning null or undefined results in
no item added to the new array.
As with most jQuery callback functions,
this refers to the current element within
the callback function, and the callback func-
tion is provided the argument list:
offset, element.
Returning true from the callback function
provides a result similar to a continue state-
ment. Returning false provides a result simi-
lar to a break statement.
jQuery
$(Array).map(
function(key, value)
)
Like each(), each array item is passed into
a callback function. The return value of each
callback function is used to build a new array,
creating a mapping to a new array. Returning
the item or array of items includes it in the
new array. Returning null or undefined
results in no item added to the new array.
As with most jQuery callback functions, this
refers to the current item within the callback
function, and the callback function is provided
the argument list: key, value.
Returning true from the callback function
provides a result similar to a continue state-
ment. Returning false provides a result simi-
lar to a break statement.
Array
next([selector]) Selects the next sibling element; the
selector argument is optional.
jQuery
nextAll([selector]) Selects all subsequent sibling elements; the
selector argument is optional.
jQuery
(continued)
http://www.it-ebooks.info
elliott
(Elliott)
#1