Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looping through all select elements with JavaScript Prototype library

How can I (if it is possible) use the Prototype library to loop through all select elements on a page and access the element? In the documentation I found easily shortcuts for referencing elements with certain ids, class names etc. but no reference for elements with certain tag names.

If this is not possible with Prototype, an example with JQuery or another JS Library would be appreciated.

like image 221
simon Avatar asked Mar 30 '09 14:03

simon


1 Answers

Check out the first example in this page:

$$('select').each(function() {
    //
});

Essentially, the $$ function expects a CSS selector, and a tag name is a perfectly valid selector.

like image 147
Paolo Bergantino Avatar answered Oct 06 '22 13:10

Paolo Bergantino