Started

Selectors

Utilities

Animation

AJAX

CSS

Event

Manipulation

Cookie

String

Attributes

Data

Storage

Miscellaneous

$each

Iterate array or object over.
$each( haystack, callback )
  1. haystack [object]
    The array or object.
  2. callback [function]
    The function will be execute for each item. [function(index, item) for array / function(key, value) for object]

Notes

This is the most useful function on Qatrix to iterate the array or object over.

Example

HTML code
<div id="message1"></div>
<div id="message2"></div>
<button onclick="start_foreach()">Start foreach</button>
JavaScript code
function start_foreach()
{
	var new_array = [30, 50, 64, 31, 39],
		new_object = {
			"quack": "verb",
			"quadruple": "verb",
			"quaint": "adj",
			"qualification": "noun"
		},
		message1,
		message2;

	message1 = message2 = "";

	$each(new_array, function (i, item)
	{
		message1 += "array[" + i + "] = " + item + "<br />";
	});
	$html($("message1"), message1);
	
	$each(new_object, function (key, value)
	{
		message2 += "object[" + key + "] = " + value + "<br />";
	});
	$html($("message2"), message2);
}
Demonstration