jquery06 jQuery.extend 给jQuery函数添加、继承 静态方法
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>
jQuery.extend({//给jQuery函数添加的静态方法 expando : 生成唯一JQ字符串(内部)
noConflict() : 防止冲突
isReady : DOM是否加载完(内部)
readyWait : 等待多少文件的计数器(内部)
holdReady() : 推迟DOM触发
ready() : 准备DOM触发
isFunction() : 是否为函数
isArray() : 是否为数组
isWindow() : 是否为window
isNumeric() : 是否为数字
type() : 判断数据类型
isPlainObject() : 是否为对象自变量
isEmptyObject() : 是否为空的对象
error() : 抛出异常
parseHTML() : 解析节点
parseJSON() : 解析JSON
parseXML() : 解析XML
noop() : 空函数
globalEval() : 全局解析JS
camelCase() : 转驼峰(内部)
nodeName() : 是否为指定节点名(内部)
each() : 遍历集合
trim() : 去前后空格
makeArray() : 类数组转真数组
inArray() : 数组版indexOf
merge() : 合并数组
grep() : 过滤新数组
map() : 映射新数组
guid : 唯一标识符(内部)
proxy() : 改this指向
access() : 多功能值操作(内部)
now() : 当前时间
swap() : CSS交换(内部) }); jQuery.ready.promise = function(){}; 监测DOM的异步操作(内部) function isArraylike(){} 类似数组的判断(内部)
</script>
</head> <body>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script> var $ = 123;
var jQuery = 456;
js源码里面有 _jQuery = window.jQuery,_$ = window.$,此时_$ = 123,_jQuery=456
</script>
<script src="jquery-203.js"></script>
<script> alert( $.expando );//jQuery20308751509357000222
---------------------------------------------------------------------------------
//$() jQuery() 这2个是jQuery对外提供的接口,其他的库也有$,
var miaov = $.noConflict(true);//miaov就当$来用了
var $ = 123;//要写到下面,写到上面$已经是123,就不能调用noConflict方法了,
miaov(function(){//$(function(){})
alert($);
alert( jQuery );
});
---------------------------------------------------------------------------------
$(function(){});//等dom(标签)加载完就走,<img>标签是先加载标签然后加载图片资源,这个方法等标签dom加载完就走,先于window.onload。dom加载完会触发原生的DOMContentLoaded事件。
/*$(function(){})在init方法中调用的是rootjQuery.ready(function(){})就是$(document).ready(function(){})就是$().ready(function(){})(不同于$.ready(),前者是实例的方法,后者是类的静态方法,方法的实现不一样),
ready: function( fn ) {
jQuery.ready.promise().done( fn );
return this;
},
jQuery.ready.promise()创建了一个延迟对象,等到时机执行fn函数,异步操作,
jQuery.ready.promise()最终都是调的$.ready(),
$.ready()最终走readyList.resolveWith( document, [ jQuery ] );然后触发函数fn执行。
*/ window.onload = function(){//等页面中所有东西都加载完,才走这里
}; ----------------------------------------------------------------------- $(function( arg ){
alert(arg);//jQuery函数
}); $(document).ready(function(){
}); $(document).on('ready',function(){
alert(123);
});
------------------------------------------------------------------
$.holdReady(true);//推迟
$(function( ){
alert(123);//不弹出来
});
$.holdReady(true);//释放推迟
---------------------------------------------------------------------
readyList.resolve(); --------------------------------------------------------------------- $.getScript('a.js',function(){//动态加载js,异步加载,有可能alert(2)先于a.js加载完
});
$(function(){
alert(2);
});
--------------------------------------------------------------------------
$.holdReady(true);
$.getScript('a.js',function(){//动态加载js,异步加载
$.holdReady(false);//a.js加载完后回调函数执行,释放hold,保证先加载a.js,然后弹出alert(2)
});
$(function(){
alert(2);
});
----------------------------------------------------------------------
$.holdReady(true); $.getScript('b.js',function(){
$.holdReady(false);
}); $.holdReady(true); $.getScript('c.js',function(){
$.holdReady(false);
}); --------------------------------------------------------------------- </script>
</head> <body>
<div>aaaaa</div>
<img src="">
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-2.0.3.js"></script>
<script> function show(){
}
alert( $.isFunction([]) );
alert( typeof alert );//低版本是object,高版本是function alert( isFunction(alert) );
function isFunction(fn){ //jquery提供的兼容方法 if( !fn )
return false;
var s = "toString",
v = "valueOf",
t = typeof fn[s] === "function" && fn[s],
o = typeof fn[v] === "function" && fn[v],
r;
if( t )
delete fn[s];
if( o )
delete fn[v];
r = typeof fn !== "string" && !(fn instanceof String) && !fn.nodeName && fn.constructor != Array && /^[\s[]?function/.test(fn + "");
if( t )
fn[s] = t;
if( o )
fn[v] = o;
return r; } alert( Array.isArray([]) ); alert( $.isWindow(window) ); alert( null == null );//true
alert(undefined == null);//true var a = 10;
window.a = 10; window.open();//window是浏览器窗口 alert( typeof NaN );//number alert( $.isNumeric(123) ); alert( isFinite( Number.MAX_VALUE + Number.MAX_VALUE ) ); var a = new Date;
alert( typeof a );//原生typeof对于复杂类型都是object,
alert( $.type(a) );//时间:Date,数组:array,'ss':string,{}:object,null:null alert( {}.toString.call([]));//[object Array]
alert( {}.toString.call([]) =='[object Array]' );
alert( {}.toString.call(new Date) );//
alert( {}.toString.call(111) );//[object Number]
alert( {}.toString.call('111') );//[object String]
alert( $.type(undefined) ); //'undefined'
alert( {}.toString.call(function f(){}) );//[object Function]
alert( $.type([]) ); //'[object Array]' -> array </script>
</head> <body>
</body>
</html>
jquery06 jQuery.extend 给jQuery函数添加、继承 静态方法的更多相关文章
- 区别和详解:jQuery extend()和jQuery.fn.extend()
1.认识jQuery extend()和jQuery.fn.extend() jQuery的API手册中,extend方法挂载在jQuery和jQuery.fn两个不同对象上方法,但在jQuery内部 ...
- (扫盲)jQuery extend()和jQuery.fn.extend()的区别
1.认识jQuery extend()和jQuery.fn.extend() jQuery的API手册中,extend方法挂载在jQuery和jQuery.fn两个不同对象上方法,但在jQuery内部 ...
- jQuery extend()和jQuery.fn.extend()区别和详解
1.认识jQuery extend()和jQuery.fn.extend() jQuery的API手册中,extend方法挂载在jQuery和jQuery.fn两个不同对象上方法,但在jQuery内部 ...
- jQuery.extend和jQuery.fn.extend的区别【转】
解释的很有意思,清晰明了又有趣,转来分享下,哈哈哈 jQuery.extend和jQuery.fn.extend的区别,其实从这两个办法本身也就可以看出来.很多地方说的也不详细.这里详细说说之间的区别 ...
- jQuery.extend()、jQuery.fn.extend()扩展方法示例详解
jQuery自定义了jQuery.extend()和jQuery.fn.extend()方法.其中jQuery.extend()方法能够创建全局函数或者选择器,而jQuery.fn.extend()方 ...
- jQuery中jQuery.extend() 和 jQuery.fn.extend()的功能和区别
昨天下午和今天上午断断续续的一直在看jQuery中jQuery.extend() 和 jQuery.fn.extend()两个函数的功能及区别,现在自认为是掌握的差不多了.好记性不如烂笔头,这里一方面 ...
- Jquery.extend()和jQuery.fn.extend(object);
摘自: jquery $.fn $.fx是什么意思有什么用_jquery_脚本之家 jQuery.extend(object); 为扩展jQuery类本身.为类添加新的方法. jQuery.fn.ex ...
- jQuery.extend()、jQuery.fn.extend()扩展方法具体解释
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/dreamsunday/article/details/25193459 jQuery自己定义了jQu ...
- jQuery.extend和jQuery.fn.extend的区别?
jquery 本身 是由 Resig: 莱希格, 一个美国的小伙子小伙伴开发的, 在2005年 prototype发表之后, 在2006年1月发表的, 后来进入mozilla工作, mozilla的j ...
随机推荐
- [学习笔记]AJAX学习
AJAX学习 ——在w3cschool学习AJAX的学习笔记 参考网站:w3cschool XMLHttpRequest 是 AJAX 的基础. XMLHttpRequest 对象 所有现代浏览器均支 ...
- Sql Server 基本数据类型
第一大类:整数数据 bit:bit数据类型代表0,1或NULL,就是表示true,false.占用1byte. int:以4个字节来存储正负数.可存储范围为:-2^31至2^31-1. smallin ...
- js确认框confirm()用法实例详解
先为大家介绍javascript确认框的三种使用方法,具体内容如下 第一种方法:挺好用的,确认以后才能打开下载地址页面.原理也比较清晰.主要用于删除单条信息确认. ? 1 2 3 4 5 6 7 8 ...
- iOS 集成Protobuf,转换proto文件
原文地址:http://blog.csdn.net/hyq4412/article/details/54891038 附加Homebrew安装地址:https://brew.sh/index_zh-c ...
- Chromium Graphics: Aura
Aura (obsolete) This document is still good for a high level overview, with contact information, but ...
- PKU 2288 Islands and Bridges 状态dp
题意: 给你一张地图,上面有一些岛和桥.你要求出最大的三角哈密顿路径,以及他们的数量. 哈密顿路:一条经过所有岛的路径,每个岛只经过一次. 最大三角哈密顿路:满足价值最大的哈密顿路. 价值计算分为以下 ...
- Win10平台下通过VMware虚拟机安装Win7、Ubuntu、Mac
1.安装VMware14.1.1 下载地址:https://download.csdn.net/download/jasonczy/10611423 产品秘钥: CG54H-D8D0H-H8DHY-C ...
- Unity C# 设计模式(五)建造者模式
定义: 将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示. 组成部分: 1.Builder:给出一个抽象接口,以规范产品对象的各个组成成分的建造.这个接口规定要实现复杂对象的哪 ...
- HBase为什么快 HBase原理。 HBase几个问题
背景色表示可以自己做实验搞定 1 模拟一组数据 1.2.3.4.5.6.7.8.9.10 1 入 限定符 'one' 2 入 'two' 3 入 'three' 4 f ...
- Maven的SSH搭建以及部署
本人有点傻,研究Maven研究了有一段时间,刚刚有些入门,记录下来方便以后使用 工作环境:jdk7 myeclipse10 maven3.1.1 1 下载maven3.1.1 http://maven ...