02-17-2008, 06:21 AM
|
#5 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by DeMo
Yes Orc, prototype is one of the many JS libraries that work with a syntax like that.
For instance, if you need to get the value of a form field you could do it like this:
Code:
var x = document.getElementById("field_id").value;
With prototype you can do this by typing:
Code:
var x = $F("field_id");
Ultimately, prototype will simply "forward" your call to document.getElementById("..").value. But since it is a cross-browser library it will also do some browser checks and if it can't retrieve the value using document.getElementById("..").value it will use another method. Prototype frees you from doing this dirty work of browser checks and stuff like that, it also let's you write smaller and cleaner code. On the other hand, prototype is over 100k in size, keep in mind that it will be included in your pages and your visitors browser will have to download it, the good news is that the browser will probably cache it.. so you don't need to worry about it slowing the page loading time. Check the prototype documentation for more info.
Other libraries (like jQuery) also use the $() syntax. In jQuery you can use regular expressions and a lot of other stuff inside the $() that allows you to select and apply effects to various DOM elements at the same time, it's an interesting library too.
|
jQuery sounds fun. :D
__________________
VillageIdiot can have my babbies ;d
|
|
|
|