map
map(function(index, item){ ... }) ⇒ collection
遍历对象集合中的所有元素。通过遍历函数返回值形成一个新的集合对象。在遍历函数中 this
关键之指向当前循环的项(遍历函数中的第二个参数)。
遍历函数的返回值组成一个新的集合并被返回,集合中的 null
和 undefined
全部被过滤掉,不会出现在集合中。
// get text contents of all elements in collection
elements.map(function(){ return $(this).text() }).get().join(', ')