UnderZ

Javascript Library.

Loop for each value

Iterate over object/array, executing a function for each value.


Loop with array

_z.each( array, callback, args );

Returns: array (first argument) array.


Loop with DOM elements

_z(selector).each( callback, args );

Returns: _z(selector) _z.


Examples:

// 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);