Home  >  Article  >  Web Front-end  >  Detailed explanation of the basic knowledge of common functions of prototype.js

Detailed explanation of the basic knowledge of common functions of prototype.js

亚连
亚连Original
2018-05-21 09:16:501134browse

This article mainly introduces the usage of each function in prototype.js. I hope it can help everyone. Friends in need can refer to it.

## Effect.Highlight Highlight special effect. Effect.Highlight(''text1'' ) Effect.Fade Fading effect Effect.ScaleZoom in and out (percentage)
Function name Explanation Example
Element.toggle Alternately hide or show Element.toggle(''p1'',''p2'')
Element.hide Hide Element.hide(''p1'',''p2'')
Element.show Display Element.show(''p1'',''p2'')
Element.remove Delete Element.remove('' p1'',''p2'')
Element.getHeight Get the height Element.getHeight(''p1'')
Toggle.display Same as Element.toggle Toggle.display(''p1'',''p2'')
Insertion.Before Insert text before p Insertion.Before(''p1'',''my content'')
Insertion.After Inserting text after p Insertion.After(''p1'',''my content'')
Insertion.Top Insert text at the front of p Insertion.Top(''p1'',''this is a text'')
Insertion.Bottom Insert text at the end of p Insertion.Bottom(''p1'',''this is a text'')
PeriodicalExecuter Call a piece of Javascriptt with a given frequency PeridicalExecutor(test, 1)"Here test is the function of Javascriptt, 1 is the frequency (1 seconds).
$ Get a p, equivalent to getElementById() $(''p1'')
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 input box Content Field.select(''textfield1'')"
Field.activate Focus on the input box and select the input The content of the box Field.activate(''textfield1'')"
Form.serialize Convert the table content into string
Form.getElements Get the form content as an array
Form. disable disable all contents of the form Form.disable(''form1'') (This does not seem to work)
Form.focusFirstElement Focus on the first element of the form 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 Convert the content of the input box in the form into string Form.Element.serialize(''text1'')
$F Equivalent to Form.Element.getValue() $F(''text1'')
Effect.Scale(''text1'', ​​200)

​Here 200 = 200%, which is twice as much

Effect.Squish Disappearance effect. The text disappears after shrinking Effect.Squish(''text1'')
Effect.Puff Disappearance special effect. The text disappears after it is enlarged 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 Sends an Ajax request to the server and updates the specified Container with the response result Ajax.Updater( ''text1'',''http://server/s.php'')

Basic usage: prototype.js is divided into each main class A Class is very convenient to use. To produce a specific effect, just use new Class.function(c25b7b04eabbf30cdb48041613aaf91c). For example:

<p id="p1"><a href="#" onclick="new Element.toggle(&#39;p2&#39;)">Click Me</a></p>
<p id="p2">Hello!</p>

When Click Me is clicked, p2 will alternate Hide or show. Note that you can add unlimited parameters to toggle, such as Element.toggle("p2", "p3", "p4",...)

The above is what I compiled for everyone. I hope It will be helpful to everyone in the future.

Related articles:

window.close(); Close the browser windowjsCode summary (detailed explanation)

Using Js to implement several methods of deleting one or more items in an array

Detailed interpretation of Js OOP programming to create objects

The above is the detailed content of Detailed explanation of the basic knowledge of common functions of prototype.js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn