Common prototype. js Functions

Source: Internet
Author: User
Function Name explanation example
Element. Toggle alternately hide or display element. Toggle (''div1 '', ''div2 '')
Element. Hide hides element. Hide (''did'', ''did '')
Element. Show shows element. Show (''div1 '', ''div2 '')
Element. Remove Delete element. Remove (''div1 '', ''div2 '')
Element. getheight get the height element. getheight (''div1 '')
Toggle. Display and element. Toggle are the same toggle. Display (''div1 '', ''div2 '')
Insertion. Before Insert the text insertion. Before (''div1 '', ''my content'') in front of the div '')
Insertion. After insert text insertion. After (''did'', '''my content '')
Insertion. Top insert text insertion. Top (''did'', ''this is a text'') at the beginning of the div '')
Insertion. bottom insert the insertion. Bottom (''did'', ''this is a text'') in the div '')
Periodicalexecuter calls a javascript peridicalexecutor (test, 1) at a given frequency. "test is a JavaScript function, and 1 is a frequency (1 second ).
$ Get a DIV, equivalent to getelementbyid () $(''div1 '')
Field. Clear clears an input box field. Clear (''textfield1 '')
Field. Focus focuses on the input box field. Focus (''select1 '')
Field. Present determine whether the content is empty alert (field. Present (''textfield1 ''))"
Field. Select select field. Select (''textfield1 '')"
Field. Activate focuses on the input box and selects the content field. Activate (''textfield1 '')"
Form. serialize converts table content to string
Form. getelements: Get the table content as an array
Form. Disable disable all contents of the Form. Disable (''form1 '') (this does not seem to work)
Form. focusfirstelement focuses on the first element of the table form. focusfirstelement (''form1 '')
Form. Reset reset table form. Reset (''form1 '')
Form. element. getvalue: form. element. getvalue (''text1 '')
Form. element. serialize converts the content of the input box in the table to string form. element. serialize (''text1 '')
$ F is equivalent to form. element. getvalue () $ F (''text1 '')
Effect. Highlight highlight effect. effect. Highlight (''text1 '')
Effect. fade Fade Effect
Effect. Scale up and down (percentage)

Effect. Scale (''text1', 200)
Here 200 = 200%, double
Effect. Squish disappears special effect. After the text is reduced, effect. Squish (''text1') disappears '')
Effect. Puff disappears. After the text is enlarged, effect. Puff (''text1') disappears '')
Effect. appear
Effect. contentzoom zoom effect.
Ajax. Request sends an Ajax request to the server Ajax. Request (''http: // server/S. php '')
Ajax. Updater sends an Ajax request to the server and uses the response result to update the specified container 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 hide or display them alternately. Note: You can add infinite parameter to toggle, such as element. toggle.

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.