js常用屬性
總結一些js常用屬性
1.輸出語句:document.write("");
2.JS中的註釋為://
3.傳統的HTML文件順序是:document->html->(head,body)
4.一個瀏覽器視窗中的DOM順序是:window->(navigator,screen,history,location,document)
5.得到表單中元素的名稱和值:document.getElementById("表單中元素的ID號").name(或value)
6.一個小寫轉大寫的JS: document.getElementById("output").value = document.getElementById("input").value.toUpperCase();
7.JS中的值型別:String,Number,Boolean,Null,Object,Function
8.JS中的字元型轉換成數值型:parseInt(),parseFloat()
9.JS中的數字轉換成字元型:(""+變數)
10.JS中的取字串長度是:(length)
11.JS中的字元與字元相連線使用+號.
12.JS中的比較操作符有:==等於,!=不等於,>,>=,<.<=
13.JS中宣告變數使用:var來進行宣告
14.JS中的判斷語句結構:if(condition){}else{}
15.JS中的迴圈結構:for([initial expression];[condition];[upadte expression]) {inside loop}
16.迴圈中止的命令是:break
17.JS中的函式定義:function functionName([parameter],...){statement[s]}
18.當檔案中出現多個form表單時.可以用document.forms[0],document.forms[1]來代替.
19.視窗:開啟視窗window.open(), 關閉一個視窗:window.close(), 視窗本身:self.
20.狀態列的設定:window.status="字元";
;