Prototype. JS is a small JavaScript framework written by Sam Stephen enson (actually a function library), the Framework home page is: http://prototype.conio.net/
The following content is from the sources.
Lu's blog: www. lvjiyong. com
This article introduces several similar functions:$ (), $ F (), $ A, $ H,$ R.
$ ()EquivalentDocument. getelementbyid (),The intermediate parameter can be one ID or multiple IDs.
Example:
test page
welcome to the blog of Lu, I am a content 1 with the ID mydiv
welcome to the blog of Lu, I am a content 2 with the ID mytherdiv
Code
"onclick =" test1 (); ">
Username:
$ ()Is more special, mainly used inNodelistsAttribute object. Use$ A ('object id ')The returned result is a set of array objects. Hahaha, this is an object. Let's take a look at the actual application example:
<SCRIPT>
Function showoptions (){
VaR somenodelist = $ ('lstemployees'). getelementsbytagname ('option ');
VaR nodes = $ A (somenodelist );
Nodes. Each (function (node ){
Alert (node. nodename + ':' + node. innerhtml );
});
}
</SCRIPT>
<Select id = "lstemployees" size = "3">
<Option value = "1"> lvjiyong.com </option>
<Option value = "2"> www. lvjiyong. com </option>
<Option value = "3"> Lu's blog </option>
</SELECT>
<Input type = "button" value = "display options" onclick = "showoptions ();">
Lvjiyong.comWww. lvjiyong. comLu's blog
$ H ()It is a hash object that I have not actually used. It seems that it is mainly used to convert objects into parameters for easy transmission (. NET serialization is simple and clear version ?), Let's take a look at the example:
<SCRIPT>
Function testhash ()
{
// Let's create the object to create an object
VaR A = {
First: 10,
Second: 20,
Third: 30
};
// Now transform it into a hash to convert to hash
VaR H =$ H ();
Alert (H. toquerystring (); // convert to a string. Hahaha can use ajax to upload the attributes of this object to the backend with displays: First = 10 & Second = 20 & third = 30
}
</SCRIPT>
Next we will talk about the last function today:$ R ()
The$ R ()Function is simply a short hand to writingNew objectrange (lowerbound, upperbound, excludebounds). Ha, this is definitely a very interesting function: Specify the upper and lower limits to return your ordered Range
Example:
<SCRIPT>
Function demodollar_r (){
VaR range =$ R (10, 20, false);
Range. Each (function (value, index ){
Alert (value );
});
}
</SCRIPT>
<Input type = "button" value = "$ r example" onclick = "demodollar_r ();">
The code word is really tired. I haven't modified it and translated it for a long time. Come here first.