基礎的prototype.js常用函數及其用法
2024-09-06 12:43:01
供稿:網友
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
把焦點集中在表格第一個元素上