PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Eight Weeks of Prototype: Week 3, Prototype Data Types

Other Enumerable Methods

In addition to each(), there are a number of other methods that can be used with enumerable objects. There are many different functions available (too many to cover here), but you can read about all of them at http://prototypejs.org/api/enumerable.

One example of one of these useful extra methods is invoke(). This method allows you to call a single function on each element in the enumerable.

For example, if you use $$() to select a number of elements, you can hide all elements by using invoke() to apply the hide() method. That is, you can use $$('#foo li').invoke('hide').

You can also pass arguments for the method to invoke. For example, to remove the active class name from all elements, you could use $$('#foo li').invoke('removeClassName', 'active').

In This Article