*** Welcome to piglix ***

Prototype.js

Prototype
Original author(s) Sam Stephenson
Developer(s) Prototype Core Team
Initial release February 2005; 12 years ago (2005-02)
Stable release
1.7.3 / September 22, 2015; 2 years ago (2015-09-22)
Repository Edit this at Wikidata
Development status Active
Written in JavaScript
Type JavaScript library
License MIT License
Website prototypejs.org

The Prototype JavaScript Framework is a JavaScript framework created by Sam Stephenson in February 2005 as part of the foundation for Ajax support in Ruby on Rails. It is implemented as a single file of JavaScript code, usually named prototype.js. Prototype is distributed standalone, but also as part of larger projects, such as Ruby on Rails, script.aculo.us and Rico. As of November 2015, according to one survey, Prototype is used by 2.2% of all websites.

Prototype provides various functions for developing JavaScript applications. The features range from programming shortcuts to major functions for dealing with XMLHttpRequest.

Prototype also provides library functions to support classes and class-based objects, something the JavaScript language lacks. In JavaScript, object creation is prototype-based instead: an object creating function can have a prototype property, and any object assigned to that property will be used as a prototype for the objects created with that function. The Prototype framework is not to be confused with this language feature.

The dollar function, $(), can be used as shorthand for the getElementById function. To refer to an element in the Document Object Model (DOM) of an HTML page, the usual function identifying an element is:

The $() function reduces the code to:

The $() function can also receive an element as parameter and will return, as in the previous example, a prototype extended object.

Building on the $() function: the $F() function returns the value of the requested form element. For a 'text' input, the function will return the data contained in the element. For a 'select' input element, the function will return the currently selected value.

The dollar dollar function is Prototype's CSS Selector Engine. It returns all matching elements, following the same rules as a selector in a CSS stylesheet. For example, if you want to get all <a> elements with the class "pulsate", you would use the following:


...
Wikipedia

...