Javascript Library.
Commands 0 |
---|
Iterate over object/array, executing a function for each value.
_z.each( array, callback, args );
Returns: array (first argument) array.
_z(selector).each( callback, args );
Returns: _z(selector) _z.
// array to loop over
var array = [ 1, "a", [ 3 ] ];
_z.each( array, function(index, value) {
// log the value if its a number.
if( _z.isNumber(value) ) console.log(value);
});
// bind argument to loop
var dataToAttach = [ 123, "second arg" ];
// element/s to loop over
_z("input").each(function( index, element ) {
// index = dataToAttach[0];
// element = dataToAttach[1];
// change input value
_z(this).val( "-" );
}, dataToAttach);