Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use prototype.js function

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to use the prototype.js function. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Function name interpretation example Element.toggle alternately hides or shows Element.toggle (''div1'',''div2'') Element.hide hidden Element.hide (' 'div1'',''div2'') Element.show shows Element.show (' 'div1'',''div2'') Element.remove deletes Element.remove (' 'div1'',''div2'') Element.getHeight obtains height Element.getHeight (' 'div1'') Toggle.display and Element.toggle same Toggle.display (' 'div1'' '' div2'') Insertion.Before inserts text before DIV Insertion.Before (''div1'',''my content'') Insertion.After inserts text after DIV (' 'div1'',''my content'') Insertion.Top inserts text first in DIV (' 'div1'',''this is a text'') Insertion.Bottom inserts text Insertion.Bottom (' 'div1'') last in DIV '' this is a text'') PeriodicalExecuter calls a segment of JavaScriptPeridicalExecutor (test, 1) at a given frequency. "where test is a function of Javascript, and 1 is the frequency (1 second). $gets a DIV Equivalent to getElementById () $(''div1'') Field.clear emptying an input box Field.clear (' 'textfield1'') Field.focus focuses on the input box Field.focus (' 'select1'') Field.present determines whether the content is empty alert (Field.present (' 'textfield1'')) "Field.select select the content of the input box Field.select (' 'textfield1'')" Field.activate focuses on the input box and selects Select the contents of the input box Field.activate (''textfield1'') "Form.serialize to convert the table contents into string

Form.getElements gets the contents of the table as an array.

All the contents of the Form.disabledisable form Form.disable (''form1'') (this does not seem to be work) Form.focusFirstElement focuses on the first element of the table Form.focusFirstElement (' 'form1'') Form.resetReset table Form.reset (' 'form1'') Form.Element.getValue gets the value of the form input box Form.Element.getValue (' 'text1'') Form.Element.serialize converts the contents of the input box in the table into stringForm.Element.serialize (' 'text1'') $F is equivalent to Form.Element.getValue () $F (' 'text1'') Effect.Highlight highlight special effects. Effect.Highlight (' 'text1'') Effect.Fade fading special effects

Effect.Scale zooms in and out (percentage)

Effect.Scale (''text1'', 200)

Here 200 = 200%, that's twice as much

Effect.Squish disappears special effects. Effect.Squish (''text1'') Effect.Puff disappears after text shrinks. Effect.Puff (' 'text1'') Effect.Appear appears special effects when text is enlarged

Effect.ContentZoomZOOM special effects.

Ajax.Request sends the Ajax request to the server Ajax.Request (''http://server/s.php'')Ajax.Updater sends the Ajax request to the server and updates the specified ContainerAjax.Updater (' 'text1'','' http://server/s.php'')') with the result of the reply

Basic usage: prototype.js assigns a Class to each major class, which is easy to use. To have a specific effect, just use new Class.function (). For example:

Click Me

Hello!

When you click Click Me, div2 will be hidden or displayed alternately. Note that you can add unlimited parameter to toggle, such as Element.toggle (''div2'',''div3'',''div4'',...).

Thank you for reading! This is the end of the article on "how to use the prototype.js function". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report