(function(window, undefined) {
//- 模块
(21,94) :定义了一些变量和函数 jQuery = function() {};
//- 模块解析
{
//-- 变量
rootjQuery :等于jQuery(document)
readyList :DOM遍历
_jQuery = window.jQuery; // 防冲突
_$ = window.$; // 防冲突
class2type: {}; // $.type() 时用到,判断变量类型
core_deletedIds = []; // 2.x之前与数据存储相关,2.x版本之后基本没有作用了
//-- jQuery() 函数 返回一个对象
jQuery = function(selector, context){
return new jQuery.fn.init(selector, context, rootjQuery);
}
//-- 正则
core_pnum :匹配数字,在css() 中会用到;
core_rnotwhite :以空格进行分割;
rquickExpr :匹配标签,匹配id,防xss注入,<p>aaa 或 #div1
rsingleTag :匹配成对的标签 <p></p>
rmPrefix :js转css内容,-ms-margin-left: MsMarginLeft, -webkit-margin-left: webkitMarginLeft
rdashAlpha :将 -数字 转成 数字,将 -字母 转成 大写字母
//-- 函数
fcamelCase = function() {}; // 转驼峰的回调函数
complated = function() {}; // DOM加载成功的回调函数
}
})(window)
【知识点梳理】
1、jQuery原型应用解析,即jQuery构造函数分析
function jQuery() {
return new jQuery.fn.init();
}
jQuery.prototype.init = function(){};
jQuery.prototype.css = function(){};
jQuery.fn = jQuery.prototype; // 源码96行
jQuery.fn.init.prototype = jQuery.fn; // 源码283行
// 调用方式
jQuery().css();
【小知识点梳理】
1、变量的使用
a = a + 10; // 不推荐
var speed = 10; a = a + speed; // 推荐用法
2、判断 undefined
window.a === undefined; // 不推荐
typeof window.a === 'undefined'; // 推荐
3、window.document === document; // true
docElem = document.documentElement; // ???