夢想飛翔

          自強不息
          posts - 111, comments - 30, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          prototype.js常用函數及其用法

          Posted on 2007-08-14 13:29 love1563 閱讀(279) 評論(0)  編輯  收藏 所屬分類: JSP/Servlets/JSF

          關鍵詞prototype.js ?? ??????????????????????????????????????

          ????? 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'')

          ????? 基本用法: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(''div2'',''div3'',''div4'',...)

          主站蜘蛛池模板: 北辰区| 当涂县| 乌鲁木齐县| 乌鲁木齐市| 梁平县| 房产| 龙泉市| 涪陵区| 阳信县| 海丰县| 湾仔区| 仁布县| 错那县| 江城| 景宁| 扎赉特旗| 东台市| 芜湖县| 乐陵市| 凤阳县| 临猗县| 迁西县| 湾仔区| 孟州市| 土默特左旗| 铜川市| 龙海市| 八宿县| 吉林省| 武安市| 泾川县| 荣昌县| 庆城县| 九台市| 亳州市| 泸州市| 岐山县| 宜君县| 开阳县| 红河县| 甘肃省|