常用Javascript語句

1、一個瀏覽器窗口中的DOM順序是:window- >(navigator,screen,history,location,document)

2、得到表單中元素的名稱和值:document.getElementById( "表單中元素的ID號 ").name(或value)

3、一個小寫轉大寫的JS: document.getElementById( "output ").value = document.getElementById( "input").value.toUpperCase();

4、JS中的值類型:String,Number,Boolean,Null,Object,Function

5、JS中的字符型轉換成數值型:parseInt(),parseFloat()

6、當文件中出現多個form表單時.可以用document.forms[0],document.forms[1]來代替.

7、彈出確認框:window.confirm();

8、彈出輸入提示框:window.prompt();

9、創建一個文檔元素:document.createElement(),document.createTextNode()

10、設置表單中所有文本型的成員的值爲空:var form = window.document.forms[0]for (var i = 0; i <form.elements.length;i ){if (form.elements.type == "text "){form.elements.value = " ";}}

11、複選按鈕在JS中判定是否選中:document.forms[0].checkThis.checked (checked屬性代表爲是否選中返回TRUE或FALSE)

12、單選按鈕組判定是否被選中也是用checked.

13、下拉列表框的值:document.forms[0].selectName.options[n].value (n有時用下拉列表框名稱加上.selectedIndex來確定被選中的值)

14、打開子窗口的父窗口爲:opener

15、JS的內建對象有:Array,Boolean,Date,Error,EvalError,Function,Math,Number,Object,RangeError,ReferenceError,RegExp,String,SyntaxError,TypeError,URIError

發佈了36 篇原創文章 · 獲贊 1 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章