Html 編碼規範css
Css 編碼規範html
Position:absolute; display: none; overflow: hidden; float: left; clear: both; width:960px; height: 300px; margin: 0; padding: 0; border: 1px solid #ccc; background: #ccc; font-family: 「verdaba」 ; font-size: 12px; font-weight: bold; color: #555; text-decoration: underline; line-height: 22px; text-align: left; vartical-align: baseline; direction: ltr; z-index: 3;數組
Js 編碼規範函數
window.onload = function() {佈局
addBtn.onclick = function() {性能
createEle();編碼
};spa
removeBtn.onclick = function() {htm
var box = document.getElementById("boxcon");對象
removeEle(box.lastChild);
};
}
(5)for循環與左括號之間"(" 之間有空格;例如:
for (var i = 0; i < obj.length; i++) {
//代碼塊
}
Fo r
註釋:每一個方法都要有必定的註釋,且寫在函數上面,函數內部的變量的註釋 可寫在後面。
字面量:建立 數組,對象,等均可以用字面量來建立。
例如:建立數組 var newArray = ["ab", "vdf"];
建立對象 var newObj = {
prop1:value1,
prop2:value2,
..
};
(6)在for循環相似這樣的代碼時, for (var I = 0; I < array.lenth; i++) {} 能夠把 對象的長度 保存到變量裏,這樣就不用每次循環都要計算一下長度 能夠提升性能。
var arrAlength = array.length;
for (var I = 0; I < arrAlength; i++) {}
(7)字符串 首選用單引號 ‘’; 必要的時候用雙引號」」;