prototype.js常用函數

來源:互聯網
上載者:User
函數名       解釋       舉例
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'')

        基本用法:prototype.js給每個主要的類都分了一個Class,使用起來很方便.要產生特定的效果,只要用new Class.function(<argument>)就可以了.例如:

<DIV id="div1"><a href="#" onclick="new Element.toggle('div2')">Click Me</a></DIV>

<DIV id="div2">Hello!</DIV>

        當點擊Click Me的時候,div2就會交替隱藏或顯示.注意,你可以給toggle加上無限個parameter,比如Element.toggle

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.