Prototype.js Common functions and usage

Source: Internet
Author: User
Tags empty functions insert reset string
The name of the function Explain Example
Element.toggle Alternately hide or show Element.toggle (' Div1 ', ' div2 ')
Element.hide Hide Element.hide (' Div1 ', ' div2 ')
Element.show Show Element.show (' Div1 ', ' div2 ')
Element.remove Delete Element.remove (' Div1 ', ' div2 ')
Element.getheight Get high Element.getheight (' Div1 ')
Toggle.display Same as Element.toggle. Toggle.display (' Div1 ', ' div2 ')
Insertion.before Insert text before a div Insertion.before (' Div1 ', ' my content ')
Insertion.after Insert text after a div Insertion.after (' Div1 ', ' my content ')
Insertion.top Insert text first in Div Insertion.top (' Div1 ', ' ' This is a text ')
Insertion.bottom Insert text last in Div Insertion.bottom (' Div1 ', ' ' This is a text ')
Periodicalexecuter Invokes a section of JavaScript at a given frequency Peridicalexecutor (test, 1) "Test is a function of JavaScript, 1 is a frequency (1 seconds)."
$ Get a div, equivalent to getElementById () $ (' Div1 ')
Field.clear Empty an input box Field.clear (' Textfield1 ')
Field.focus Focus on the input box Field.focus (' Select1 ')
Field.present Determine if the content is empty Alert (field.present (' textfield1 ')) "
Field.select Select the contents of the input box Field.select (' Textfield1 ') "
Field.activate Focus on the input box and select the contents of the input box Field.activate (' Textfield1 ') "
Form.serialize Convert the contents of a table into a string
Form.getelements Get the table contents as an array
Form.disable Disable all table contents 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 Form Form.reset (' Form1 ')
Form.Element.getValue Get the value of the form input box Form.Element.getValue (' Text1 ')
Form.Element.serialize Converts the contents of an input box in a table into a string Form.Element.serialize (' Text1 ')
$F Equivalent to Form.Element.getValue () $F (' Text1 ')
Effect.highlight Highlight Effects. Effect.highlight (' Text1 ')
Effect.fade Fading effects
Effect.scale Zoom in (%)

Effect.scale (' Text1 ', 200)
Here 200 = 200%, that is twice times

Effect.squish Vanishing effects. Text shrinks and disappears Effect.squish (' Text1 ')
Effect.puff Vanishing effects. Text enlarged and then disappeared Effect.puff (' Text1 ')
Effect.appear There's a special effect
Effect.contentzoom Zoom special effects.
Ajax.request Sending AJAX requests to the server Ajax.request (' http://server/s.php ')
Ajax.updater Sends AJAX requests to the server and updates the specified container with the results of the reply Ajax.updater (' Text1 ', ' http://server/s.php ')

Basic usage: Prototype.js A class for each major class, which is handy to use. To produce a specific effect, just use the new Class.function (). For example:

 
Hello!

When clicked click Me, the 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.