jq-reduce
v0.1.0
Published
jQuery reduce plugin
Downloads
1
Readme
jQuery reduce()
The classic example
var total = $.reduce([1, 2, 3], function(p, c) {
return p + c;
}, 0);
Reduce a jQuery collection into an Object
var refs = $('[ref]').reduce(function(p, c) {
p[c.attributes.ref.value] = c;
return p;
}, {});
Reduce a jQuery collection into an Array
var values = $(':text').reduce(function(p, c) {
p.push(c.value);
return p;
}, []);
The current item of the collection is the default context
var names = $(':input').reduce(function(p){
return p.concat(this.name);
}, []);