Search code examples
javascriptmootoolsmootools-events

Mootools each on childs


I am working on a script what uses MooTools, and i want to select all input's in one element, but the problem is that I don't know the ID of the element, the element is a variable. (In The function is formElement = $('form#aForm'))

Does someone know how I can use the each function on all input in one element. Now I am using:

$$('input').each(function(el) {
    alert(el.get('value'));
});

But this script uses all elements in the document, and I want use only the elements in formElement. How is this possible?

Tom

PS: Sorry for my bad English.


Solution

  • Use Element.getElements:

    formElement.getElements('input').each(function(el) {
        alert(el.get('value'));
    });