jQuery核心函數jquery: "3.0.0-pre"

  1. jQuery(selector,context)
    1. 核心功能都是通過這個函數實現的,selector:用來查找的字符串,context:要查找字符串的範圍,默認document;
    2. selector:可以是字符串”div”(return this.constructor(context).find(selector)),也可以是數組[“div”,”p”],還可以是函數$(function(e){console.log(e)//e爲jQuery(selector,context)相當於selector(jQuery);})。還可以是對象{},返回的是數組。
    3. 調用路徑
jQuery = function( selector, context ) {

        // The jQuery object is actually just the init constructor 'enhanced'
        // Need init if jQuery is called (just allow error to be thrown if not included)
        return new jQuery.fn.init( selector, context );
    }
    init = jQuery.fn.init=function(selector,context,root){};init.prototype = jQuery.fn;jQuery.fn.extend({find/filter/not/is})
  1. jQuery(html,props/這裏可以寫入屬性,及一些事件/)
    1. 會創建html,還是通過主接口,通過判斷是否有’<’尖括號,來判斷是創建元素,還是搜索元素;
    2. props:是作爲屬性,事件加入
  2. jQuery(callback)
1. $(function(){   //文檔就緒})
    console.log(document.readyState)//loading;
    $(function(){
        console.log(document.readyState)//interactive
    })
    console.log(document.readyState)loading;
    順序是:loading,loading,interactive;
  1. jQuery.holdReady(hold)
    1. 沒看明白,以後用到在記錄吧
發佈了80 篇原創文章 · 獲贊 9 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章