prototype function and its use of common
prototype.js commonly used functions:
Function name | Explained | Example |
Element.toggle | Alternately hide or show | 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 | Achieved a high degree of | Element.getHeight (''div1'') |
Toggle.display | And Element.toggle same | Toggle.display (''div1'','' div2'') |
Insertion.Before | Insert text before the DIV | Insertion.Before (''div1'','' my content'') |
Insertion.After | Insert text in the DIV | Insertion.After (''div1'','' my content'') |
Insertion.Top | DIV inserted before the word most | Insertion.Top (''div1'','' this is a text'') |
Insertion.Bottom | Insert text in the DIV in the final | Insertion.Bottom (''div1'','' this is a text'') |
PeriodicalExecuter | To call a given frequency JavaScript | PeridicalExecutor (test, 1) "This test is a Javascript function, 1 is the frequency (1 second). |
$ | Get a DIV, equivalent to getElementById () | $ (''Div1'') |
Field.clear | Clear input box | Field.clear (''textfield1'') |
Field.focus | To focus on input box | Field.focus (''select1'') |
Field.present | Determine whether the content is empty | alert (Field.present (''textfield1''))" |
Field.select | Select the contents of the input box | Field.select (''textfield1'') " |
Field.activate | To focus on the input box and select the contents of the input box | Field.activate (''textfield1'') " |
Form.serialize | String into the table of contents | |
Form.getElements | Table of contents for the array to obtain | |
Form.disable | disable all the contents of the form | Form.disable (''form1'') (this seems to not work) |
Form.focusFirstElement | To focus on the first element in the table | Form.focusFirstElement (''form1'') |
Form.reset | Reset Form | Form.reset (''form1'') |
Form.Element.getValue | To obtain the value of form input box | Form.Element.getValue (''text1'') |
Form.Element.serialize | The contents of the table into the input box string | Form.Element.serialize (''text1'') |
$ F | Equivalent Form.Element.getValue () | $ F (''text1'') |
Effect.Highlight | Highlight effects. | Effect.Highlight (''text1'') |
Effect.Fade | Fading effects | |
Effect.Scale | Zoom (Percentage) | Effect.Scale (''text1'', 200) Where 200 = 200%, or twice the |
Effect.Squish | Effects disappear. Reduce text disappear after | Effect.Squish (''text1'') |
Effect.Puff | Effects disappear. Enlarge text disappear after | Effect.Puff (''text1'') |
Effect.Appear | Effects appear | |
Effect.ContentZoom | ZOOM effects. | |
Ajax.Request | Send Ajax requests to the server | Ajax.Request (''http://server/s.php'') |
Ajax.Updater | Send Ajax requests to the server and use the results of updating the specified reply Container | Ajax.Updater (''text1'','' http://server/s.php'') |
Basic usage: prototype.js to each major sub-class of a Class, easy to use. To produce a particular effect, as long as new Class.function (<argument>) on it. For example:
<DIV> <a Href="#"> Click Me </ a> </ DIV>
<DIV> Hello! </ DIV>
When you click on Click Me time, div2 will alternately hide or show. Note that you can toggle with an unlimited number of parameter, such as Element.toggle (''div2'','' div3'','' div4'', ...)