文章出處

 項目結尾,空閑時間,又把《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>
View Code

 【2. 查找要素和判斷要素類型】

    發現自己離了JQuery 就有點不會寫代碼了咩,不行啊!!!

    原生態的是查找和 判斷是怎樣的呢? 

   //查找元素和判斷類型
     var findele = document.forms[0].elements[0];
     console.log("輸出要素:"+findele);
     var eletype = document.forms[0].elements[0].type;
     console.log("輸出要素類型:"+eletype);
View Code

 【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 存取

 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()