on.js Wiki
Integrated Performance Environment Library (client-side JavaScript)
Brought to you by:
clayendisk
for each property/item in data
for each
For Each Loops should be simple and universal, on.js makes everything possible in one easy step.
('for each')[on](['abc',123,'xyz',789])
( function(i) //the function to be called on every item with index [i]
{
i; //each item index
this[i]; //each item value
}
);
('for each')[on]({'abc':123,'xyz':789})
( function(name) //the function to be called on every property with index [name]
{
name; //each property name
this[name]; //each property value
}
);
Nodes
('for each')[on](document)
( function(i) //the function to be called on every element with index [i]
{
i; //each element index
this[i]; //each element
}
);
:::javascript
('for each div')[on](document)
( function(i) //the function to be called on every div with index [i]
{
i; //each div index
this[i]; //each div
}
);
Children
('for each child')[on](document)
( function(i) //the function to be called on every element with index [i]
{
i; //each child element index
this[i]; //each child element
}
);
:::javascript
('for each child div')[on](document)
( function(i) //the function to be called on every child div with index [i]
{
i; //each child div index
this[i]; //each child div
}
);
Nodes
var element = document.getElementById('the-element');
('for each')[on](element)
( function(i) //the function to be called on every element with index [i]
{
i; //each element index
this[i]; //each element
}
);
:::javascript
var element = document.getElementById('the-element');
('for each div')[on](element)
( function(i) //the function to be called on every div with index [i]
{
i; //each div index
this[i]; //each div
}
);
Children
var element = document.getElementById('the-element');
('for each child')[on](element)
( function(i) //the function to be called on every element with index [i]
{
i; //each child element index
this[i]; //each child element
}
);
:::javascript
var element = document.getElementById('the-element');
('for each child div')[on](element)
( function(i) //the function to be called on every child div with index [i]
{
i; //each child div index
this[i]; //each child div
}
);
return true;
A JavaScript Library