search
HomeWeb Front-endJS TutorialBasic prototype.js common functions and their usage_prototype

prototype.js 常用函数 : 
 Element.toggle 
   交替隐藏或显示 
  Element.toggle(''div1'',''div2'') 
 Element.hide 
   隐藏 
  Element.hide(''div1'',''div2'') 
 Element.show 
 显示 
  Element.show(''div1'',''div2'') 
 Element.remove 
   删除 
  Element.remove(''div1'',''div2'') 
 Element.getHeight 
   取得高度 
  Element.getHeight(''div1'') 
 Toggle.display 
   和 Element.toggle 相同 
  Toggle.display(''div1'',''div2'') 
 Insertion.Before 
   在 DIV 前插入文字 
  Insertion.Before(''div1'',''my content'') 
 Insertion.After 
   在 DIV 后插入文字 
  Insertion.After(''div1'',''my content'') 
 Insertion.Top 
   在 DIV 里最前插入文字 
  Insertion.Top(''div1'',''this is a text'') 
 Insertion.Bottom 
   在 DIV 里最后插入文字 
  Insertion.Bottom(''div1'',''this is a text'') 
 PeriodicalExecuter 
   以给定频率调用一段 JavaScript 
  PeridicalExecutor(test, 1)" 这里 test 是 Javascript 的函数 ,1 是频率 (1 秒 ). 
 $ 
   取得一个 DIV, 相当于 getElementById() 
  $(''div1'') 
 Field.clear 
   清空一个输入框 
  Field.clear(''textfield1'') 
 Field.focus 
 把   焦点集中在输入框上 
  Field.focus(''select1'') 
 Field.present 
   判断内容是否为空 
  alert(Field.present(''textfield1''))" 
 Field.select 
   选择输入框的内容 
  Field.select(''textfield1'')" 
 Field.activate 
   把   焦点集中在输入框上并选择输入框的内容 
  Field.activate(''textfield1'')" 
 Form.serialize 
   把表格内容转化成 string 
 Form.getElements 
   取得表格内容为数组形式 
 Form.disable 
  disable 表格所有内容 
  Form.disable(''form1'') ( 这个好象不 work) 
 Form.focusFirstElement 
   把焦点集中在表格第一个元素上 
  Form.focusFirstElement(''form1'') 
 Form.reset 
  Reset 表格 
 Form.reset(''form1'') 
 Form.Element.getValue 
   取得表格输入框的值 
  Form.Element.getValue(''text1'') 
 Form.Element.serialize 
    把表格中输入框内容转化成 string 
  Form.Element.serialize(''text1'') 
 $F 
   等同于 Form.Element.getValue() 
  $F(''text1'') 
 Effect.Highlight 
   高亮特效 . 
  Effect.Highlight(''text1'') 
 Effect.Fade 
   褪色特效 
 Effect.Scale 
   放大缩小 ( 百分比) 
 Effect.Scale(''text1'', 200)
这里 200 = 200%, 即两倍 
 Effect.Squish 
   消失特效.文字缩小后消失 
  Effect.Squish(''text1'') 
 Effect.Puff 
   消失特效.文字放大后消失 
  Effect.Puff(''text1'') 
 Effect.Appear 
   出现特效 
 Effect.ContentZoom 
  ZOOM 特效. 
 Ajax.Request 
   传送 Ajax 请求给服务器 
  Ajax.Request(''http://server/s.php'') 
 Ajax.Updater 
   传送 Ajax 请求给服务器并用答复的结果更新指定的 Container 
  Ajax.Updater(''text1'',''http://server/s.php'') 
==========================================
Basic usage: prototype.js assigns a Class to each main class, which is very convenient to use. To produce specific effects, just use new Class.function(). For example:

Click Me

Hello!

When you click Click Me, div2 will alternately hide or show. Note, you can add toggle Unlimited parameters, such as Element.toggle(''div2'',''div3'',''div4'',...)

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
Replace String Characters in JavaScriptReplace String Characters in JavaScriptMar 11, 2025 am 12:07 AM

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

Custom Google Search API Setup TutorialCustom Google Search API Setup TutorialMar 04, 2025 am 01:06 AM

This tutorial shows you how to integrate a custom Google Search API into your blog or website, offering a more refined search experience than standard WordPress theme search functions. It's surprisingly easy! You'll be able to restrict searches to y

Example Colors JSON FileExample Colors JSON FileMar 03, 2025 am 12:35 AM

This article series was rewritten in mid 2017 with up-to-date information and fresh examples. In this JSON example, we will look at how we can store simple values in a file using JSON format. Using the key-value pair notation, we can store any kind

10 jQuery Syntax Highlighters10 jQuery Syntax HighlightersMar 02, 2025 am 12:32 AM

Enhance Your Code Presentation: 10 Syntax Highlighters for Developers Sharing code snippets on your website or blog is a common practice for developers. Choosing the right syntax highlighter can significantly improve readability and visual appeal. T

Build Your Own AJAX Web ApplicationsBuild Your Own AJAX Web ApplicationsMar 09, 2025 am 12:11 AM

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

8 Stunning jQuery Page Layout Plugins8 Stunning jQuery Page Layout PluginsMar 06, 2025 am 12:48 AM

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

10  JavaScript & jQuery MVC Tutorials10 JavaScript & jQuery MVC TutorialsMar 02, 2025 am 01:16 AM

This article presents a curated selection of over 10 tutorials on JavaScript and jQuery Model-View-Controller (MVC) frameworks, perfect for boosting your web development skills in the new year. These tutorials cover a range of topics, from foundatio

What is 'this' in JavaScript?What is 'this' in JavaScript?Mar 04, 2025 am 01:15 AM

Core points This in JavaScript usually refers to an object that "owns" the method, but it depends on how the function is called. When there is no current object, this refers to the global object. In a web browser, it is represented by window. When calling a function, this maintains the global object; but when calling an object constructor or any of its methods, this refers to an instance of the object. You can change the context of this using methods such as call(), apply(), and bind(). These methods call the function using the given this value and parameters. JavaScript is an excellent programming language. A few years ago, this sentence was

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools