码迷,mamicode.com
首页 > Web开发 > 详细

jquery入口函数的测试

时间:2019-11-23 12:41:52      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:dom   null   fine   jquery   script   const   ike   charset   function   

 

/*编写一个自定义的jquery框架*/

(function (window,undefined) {
var njquery=function (selector ,) {
return new jquery .prototype.init(); /*prototype==fn*/
};
jquery.prototype={
constructor:njQuery
};

njquery.prototype.init.prototype=njquery.prototype;
window.njquery=Window.$ = njquery;
})(window);

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>02-jquery入口函数实例测试</title>
</head>
<body>


<script src="jquery-1.12.4.js"></script>
<script>
//1传入‘’ null undefined NaN 0 false
//会返回一个空的jquery对象给我们;
// console.log($())
// console.log($(null))
// console.log($(undefined))
// console.log($(NaN))
// console.log($(0))
// console.log($(false))


// 2传入代码片段
//会将创建好的DOM元素存储到jquery对象中返回
console.log($("<p>hihihihihi</p>"))
// 3传入选择器
// 会将找到的所有元素存储到jquery对象中返回
console.log($("li"))
// 4传入数组
// 会将数组中存储的元素依次存储到jquery对象中返回
console.log($([1,2,3,4,5]))
// 5传入伪数组
// 会将数组中存储的元素依次存储到jquery对象中返回
var likeArr={0:"lnj",1:"sda",2:‘asd‘}
console.log($(likeArr));
// 6传入对象值
// 会将传入的对象存储到jquery对象中返回
function Person() {}
console.log($(new Person()));

// 7传入DOM元素
// 会将传入的DOM元素存储到jquery对象中返回,
console.log($(document.createElement(‘div‘)));
//8 传入基本的数据类型
// 会将传入的基本数据类型存储到jquery对象中返回,
console.log($(123));
console.log($(true));

/*
*
* 结论: //1传入‘’ null undefined NaN 0 false 返回空的jquery对象
* 2字符串
* 3数组
* 4除上述类型以外
* */
</script>
</body>
</html>

jquery入口函数的测试

标签:dom   null   fine   jquery   script   const   ike   charset   function   

原文地址:https://www.cnblogs.com/Damocless/p/11917039.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!