The Prototype $() function

The dollar function is one of the Prototype Utility Function. $() is the most frequently used prototype’s function. basically it was used to refer an element in the HTML page. The function is quickly shorthand for getElementById.

The usual function identifying an element is:
document.getElementById("element_id")

The $() function reduces the code to:
$("element_id")

For example, you can set the CSS text color with this code:
$("element_id").style.color = "#ffffff";

Or, the “Prototype way”:
$("id_of_element").setStyle({color: '#ffffff'});

July 20th, 2008 by Admin

Prototype

Prototype is the most popular Ajax framework. It used by many giant-website such : Apple, Gucci, etc… The Prototype JavaScript Framework is a JavaScript framework created by Sam Stephenson. Prorotype is implemented as a single file of JavaScript code “prototype.js”.

Prototype is also used as the low layer for many framework, for example: script.aculo.us, Rico, ExtJS, Moo.fx, etc. Prototype provides many functions for developing JavaScript web applications. The prorotype features programming shortcuts for accessing element, events, and major functions to deal with Ajax.

Prototype also feature library functions to support object oriented programming that use classes and ojects, something the JavaScript language hard to implement.

You can find and download prototype on their site.

May 20th, 2008 by Admin