Common prototype functions

Source: Internet
Author: User
Common functions of prototype. JS:

Function Name Explanation Example
Element. Toggle Hide or show Alternately Element. Toggle (''div1 '', ''div2 '')
Element. Hide Hide Element. Hide (''div1 '', ''div2 '')
Element. Show Display Element. Show (''div1 '', ''div2 '')
Element. Remove Delete Element. Remove (''div1 '', ''div2 '')
Element. getheight Gain height Element. getheight (''div1 '')
Toggle. Display Same as element. Toggle Toggle. Display (''div1 '', ''div2 '')
Insertion. Before Insert text in front of Div Insertion. Before (''div1 '', ''my content '')
Insertion. After Insert text behind the DIV Insertion. After (''div1 '', ''my content '')
Insertion. Top Insert text at the beginning of the DIV Insertion. Top (''did'', ''this is a text '')
Insertion. Bottom Insert text at the end of the DIV Insertion. Bottom (''did'', ''this is a text '')
Periodicalexecuter Call a javascript code at a given frequency Peridicalexecutor (test, 1) "test is a JavaScript function, and 1 is the frequency (1 second ).
$ Get a DIV, which is equivalent to getelementbyid () $(''Div1 '')
Field. Clear Clear an input box Field. Clear (''textfield1 '')
Field. Focus Focus on the input box Field. Focus (''select1 '')
Field. Present Determine whether the content is empty Alert (field. Present (''textfield1 ''))"
Field. Select Select the content in the input box Field. Select (''textfield1 '')"
Field. Activate Focus on the input box and select the content in the input box. Field. Activate (''textfield1 '')"
Form. serialize Convert table content to string
Form. getelements Retrieve the table content in array format
Form. Disable Disable table content Form. Disable (''form1 '') (this does not seem to work)
Form. focusfirstelement Focus on the first element of the table Form. focusfirstelement (''form1 '')
Form. Reset Reset table Form. Reset (''form1 '')
Form. element. getvalue Get the value of the table input box Form. element. getvalue (''text1 '')
Form. element. serialize Convert the input box content in the table to string Form. element. serialize (''text1 '')
$ F Equivalent to form. element. getvalue () $ F (''text1 '')
Effect. Highlight Highlight special effects. Effect. Highlight (''text1 '')
Effect. Fade Fade Effect
Effect. Scale Zoom in/out (percentage)

Effect. Scale (''text1', 200)
Here 200 = 200%, double

Effect. Squish Disappear special effect. The text disappears after being zoomed out. Effect. Squish (''text1 '')
Effect. Puff Disappear special effect. After the text is zoomed in, it disappears. Effect. Puff (''text1 '')
Effect. appear Special effects
Effect. contentzoom Zoom effect.
Ajax. Request Send Ajax requests to the server Ajax. Request (''http: // server/S. php '')
Ajax. Updater Send an Ajax request to the server and update the specified iner with the response result. Ajax. Updater (''text1', ''http: // server/S. php '')

Basic usage: prototype. JS divides every major class into a class, which is easy to use. to produce a specific effect, you only need to use new class. function (<argument>. for example:

 
<Div id = "div1"> <a href = "#" onclick = "new element. Toggle ('div2')"> click me </a> </div>
<Div id = "div2"> hello! </Div>

When you click "Click me", div2 will be hidden or displayed alternately. note that you can add infinite parameter to toggle, such as element. toggle (''div2'', ''div3 '', ''div4 '',...)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.