<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
</head>
<body>
<div id="d">divvv</div>
<div id="fsd">fdsf</div>
</body>
</html>
<script type="text/javascript">
//实现自己的MyQuery框架
var MyQuery = function(selector){
if ( window == this ) return new MyQuery(selector);
//这里只实现dom类型的简单查找,嘿嘿
var doms = document.getElementsByTagName(selector);
var arr = [];
for(var i=0; i<doms .length; i++){
arr.push(doms.item(i));
}
return this.setArray(arr);
}
MyQuery.prototype.setArray = function( arr ) {
this.length = 0;
[].push.apply( this, arr );
return this;
}
MyQuery.fn = MyQuery.prototype;
var $ = MyQuery;
//插件扩展 1)each
MyQuery.fn.each = function(method){
for(var i=0,l=this.length; i<l; i++){
method.call(this[i],i);
}
}
//插件扩展 2)show
MyQuery.fn.show = function(){
this.each(function(i){
<!-- alert("第 "+i+" 个div : id= "+this.id+" : 内容:"+this.innerHTML); -->
console.log("第 "+i+" 个div : id= "+this.id+" : 内容:"+this.innerHTML);
});
}
//debugger
$("div").show();
//第 0 个div : id= d : 内容:divvv
//第 1 个div : id= fsd : 内容:fdsf
</script>

最新文章

  1. Linux下安装php加速软件Xcache
  2. 如何制定tomcat部署时自己定义的docBase路径
  3. 内存中 OLTP - 常见的工作负荷模式和迁移注意事项(一)
  4. CSS 实现加载动画之四-圆点旋转
  5. XSS转码 &amp;amp;&amp;amp; struts2 property标签的bug
  6. exception -----&gt; Typedefs &amp; Classes
  7. [BILL WEI]SQL 如何将查询到的列作为表名去查询数据
  8. 《深入理解linux内核架构》第二章 进程管理和调度
  9. (转)关于font-size:100%
  10. NAND FLASH ECC校验原理与实现
  11. IM设计与实现的系统模块的聊天记录
  12. spring或springmvc自动生成applicationcontext.xml或springmvc文件(此文转载和借鉴多篇文章)
  13. 【笔记】vue-cli 开发环境中跨域连接后台api(vue-resource 跨域post 请求)
  14. Exynos4412交叉编译环境搭建
  15. Effective C++总结
  16. Hdoj 4508.湫湫系列故事——减肥记I 题解
  17. HDU 4463 Outlets 【最小生成树】
  18. SpringBoot使用CORS解决跨域请求问题
  19. node之常用模块
  20. 【Source Insight 】之marco学习笔记1

热门文章

  1. vue-router 导航守卫
  2. C#趣味程序---水仙花数
  3. Android实现炫酷SVG动画效果
  4. PICT工具安装使用
  5. RabbitMQ功能测试+性能测试简单方法
  6. nginx uri和request_uri区别
  7. Heterogeneity Wins
  8. Junit的各种断言
  9. vs2013中opencv的配置
  10. 地形混合shader