| Function name | explain | Give an 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 height | Element.getHeight(''div1'') |
| Toggle.display | Same as Element.toggle | Toggle.display(''div1'',''div2'') |
| Insertion.Before | Insert text before DIV | Insertion.Before(''div1'',''my content'') |
| Insertion.After | Insert text after DIV | Insertion.After(''div1'',''my content'') |
| Insertion.Top | Insert text in front of DIV | Insertion.Top(''div1'',''this is a text'') |
| Insertion.Bottom | Insert text in DIV | Insertion.Bottom(''div1'',''this is a text'') |
| PeriodicalExecuter | Calling a Javascriptt at a given frequency | PeridicalExecutor(test, 1)"Here test is a Javascript function, 1 is the frequency (1 second). |
| $ | Get a DIV, 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 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 table content into string | |
| Form.getElements | Get the table content in an array form | |
| Form.disable | All contents of the disable form | Form.disable(''form1'') (This doesn't 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 table input box | Form.Element.getValue(''text1'') |
| Form.Element.serialize | Convert the input box content in the table into string | Form.Element.serialize(''text1'') |
| $F | Equivalent to Form.Element.getValue() | $F(''text1'') |
| Effect.Highlight | Highlight special effects. | Effect.Highlight(''text1'') |
| Effect.Fade | Fading effects | |
| Effect.Scale | Zoom in and out (percentage) | Effect.Scale(''text1'', 200) Here 200 = 200%, that is, twice |
| Effect.Squish | Disappearing special effects. The text disappears after shrinking | Effect.Squish(''text1'') |
| Effect.Puff | Disappearing special effects. The text disappears after enlargement | Effect.Puff(''text1'') |
| Effect.Appear | Special effects appear | |
| Effect.ContentZoom | ZOOM special effects. | |
| Ajax.Request | Send Ajax request to the server | Ajax.Request(''http://server/s.php'') |
| Ajax.Updater | Send Ajax request to the server and update the specified Container with the reply result | Ajax.Updater(''text1'',''http://server/s.php'') |
Basic usage: Prototype.js divides each major class into a Class, which is very convenient to use. To produce a specific effect, just use new Class.function(<argument>). For example:
Copy the code as follows:<DIV id="div1"><a href="#" onclick="new Element.toggle('div2')">Click Me</a></DIV>
<DIV id="div2">Hello!</DIV>
When clicking on Click Me, div2 will be hidden or displayed alternately. Note that you can add unlimited parameters to toggle, such as Element.toggle("div2","div3","div4",...)
To view more JavaScript syntax, you can follow: "JavaScript Reference Tutorial" and "JavaScript Code Style Guide". I also hope that everyone will support Wulin.com more.