文章出處
View Code
View Code
文章列表
項目結尾,空閑時間,又把《JS 基礎知識》 這本書過了一遍,溫故知新后,很多知其然不知其所以然的內容 豁然開朗。
【1. 用于范圍的標簽】
display :inline or block 可切換

1 <p>1.兩個用于標出范圍的標簽</p> 2 <div>2. div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素div 屬于塊級元素</div> 3 <a>3.A標簽</a><div class="bdiv">4.空的div</div> 4 <span class="bspan">5. span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素span屬于行級元素</span>
【2. 查找要素和判斷要素類型】
發現自己離了JQuery 就有點不會寫代碼了咩,不行啊!!!
原生態的是查找和 判斷是怎樣的呢?

//查找元素和判斷類型 var findele = document.forms[0].elements[0]; console.log("輸出要素:"+findele); var eletype = document.forms[0].elements[0].type; console.log("輸出要素類型:"+eletype);
【3. 文檔級別對象】
top == self == document
【4. 牛X的正則表達式】
分割對象,RegExp.$X 全局
// 對正則表達式的操作 var regclick = function(){ // 正則表達式 替換 /\S*_off\S*/ 在文本的任何地點 替換掉 _off var re = /^(\S)(\S+)\s(\S)(\S+)$/; // 按照空格分割開的數據集 var res = re.exec("reg exc"); // 正則之后的數據在RegExp 中 $_ 是第一個,$1 是第二個 以此類推 var reafter = RegExp.$1.toUpperCase() + RegExp.$2.toLowerCase() + RegExp.$3.toUpperCase() + RegExp.$4.toLowerCase(); var newText = document.createTextNode(reafter); document.getElementById("reg").appendChild(newText); };
【5. cookie】
document.cookie 存取
文章列表
全站熱搜