当前位置: 首页 > news >正文

seo如何选择网站标题企业专业网站建设哪家好

seo如何选择网站标题,企业专业网站建设哪家好,网站诊断内容,wordpress文字颜色循环遍历一个元素是开发中最常见的需求之一#xff0c;那么让我们来看一个由框架BASE2和Jquery的结合版本吧.上一次的错误太多#xff0c;排版也出现了问题#xff0c;重写了一遍#xff0c;希望大家支持.循环遍历一个元素是开发中最常见的需求之一#xff0c;那么让我们来…循环遍历一个元素是开发中最常见的需求之一那么让我们来看一个由框架BASE2和Jquery的结合版本吧.上一次的错误太多排版也出现了问题重写了一遍希望大家支持.循环遍历一个元素是开发中最常见的需求之一那么让我们来看一个由框架BASE2和Jquery的结合版本吧.var forEach (function(){//数组与伪数组的遍历var _Array_forEach function (array, block, context) {if (array null) return;//对String进行特殊处理if(typeof array string){array array.split();}var i 0,length array.length;for (;i length block.call(context, array[i], (i1), array)!false; i) {}};//对象的遍历var _Function_forEach function (object, block, context) {for (var key in object) {//只遍历本地属性if (object.hasOwnProperty(key)block.call(context, object[key], key, object)false){break;}}};return function(object, block, context){if (object null) return;if (typeof object.length number) {_Array_forEach(object, block, context);}else{_Function_forEach(object, block, context);}};})()函数本身并不复杂但很精巧。加了一些简单的注释想信大家能看懂。来看一点例子//1:1 \n 2:2forEach([1,2,3,4,5],function(el,index){if(index2){return false;}alert(index:el);});function print(el,index){alert(index:el);}//a:a \n b:b \n c:cforEach({a:a,b:b,c:c},print);//1:笨 \n 2:蛋 \n 3:的 \n 4:座 \n 5:右 \n 6:铭forEach(笨蛋的座右铭,print);function Person(name, age) {this.name name || ;this.age age || 0;};Person.prototype new Person;var fred new Person(笨蛋的座右铭, 25);fred.language chinese;//极晚绑定//name:jxl \n age:22 \n language:chineseforEach(fred,print);注回调函数中的index参数下标从1开始为什么不用内置的forEach和getElementsByClassName一样内置的forEach效率很高但是在功能上有局限性它无法在循环中途退出。而在我们这个forEach中它可以在处理函数内通过返回false的方式退出循环更加的灵活。特别的length属性length属性是一个很特别的属性看到数组大家一定会想到length,那看到带有length属性的对象呢那大家一定要想到伪数组(类数组)。那什么是伪数组呢简单的理解就是能通过Array.prototype.slice转换为真正的数组的带有length属性的对象。javascript最为著名的伪数组就是arguments对象。关于伪数组有很多东西以后我会专门写一篇博文讲这个东西。大家只要记住:不要随便给对象赋予length属性除非你明确的知道你准备把它当作伪数组来使用。我想这个函数是一个简单javascript工具库中的必备函数,它是金字塔的根基在它的基础上进行再封装可以让你的库更强大,更加美丽!以下是补充在Base2中找到一个叫forEach的函数是我见过的最好的实现。挖出来分析一下。它能对各种普通对象字符串数组以及类数组进行遍历。如果原游览器的对象已实现此函数它则调用原对象的函数。function forEach(object, block, context, fn) {if (object null) return;if (!fn) {if (typeof object function object.call) {//遍历普通对象fn Function;} else if (typeof object.forEach function object.forEach ! arguments.callee) {//如果目标已经实现了forEach方法则使用它自己的forEach方法(如标准游览器的Array对象)object.forEach(block, context);return;} else if (typeof object.length number) {// 如果是类数组对象或IE的数组对象_Array_forEach(object, block, context);return;}}_Function_forEach(fn || Object, object, block, context);};function _Array_forEach(array, block, context) {if (array null) return;var i 0,length array.length;if (typeof array string) {for (; i length; i) {block.call(context, array.charAt(i), i, array);}}else{for (;i length; i) {block.call(context, array[i], i, array);}}};_Function_forEach function(fn, object, block, context) {// 这里的fn恒为Functionfor (var key in object) {//只遍历本地属性if (object.hasOwnProperty(key)) {//相当于 block(object[key], key)block.call(context, object[key], key, object);}}};原作者的一些例子(我FQ扒过来了)function print(el,index){alert(index : el)}forEach ([1, 2, 3], print);forEach ({a: aa, b: bb,c: cc}, print);forEach (司徒正美, print);forEach(document.styleSheets,function(el){if(el.href) alert(el.href)});司徒正美的function forEach(object, block, context, fn) {if (object null) return;if (!fn) {if (typeof object function object.call) {//遍历普通对象fn Function;} else if (typeof object.forEach function object.forEach ! arguments.callee) {//如果目标已经实现了forEach方法则使用它自己的forEach方法(如标准游览器的Array对象)object.forEach(block, context);return;} else if (typeof object.length number) {// 如果是类数组对象或IE的数组对象_Array_forEach(object, block, context);return;}}_Function_forEach(fn || Object, object, block, context);};function _Array_forEach(array, block, context) {if (array null) return;var i 0,length array.length;if (typeof array string)array array.split();for (;i length; i) {block.call(context, array[i], i, array);}};_Function_forEach function(fn, object, block, context) {// 这里的fn恒为Functionfor (var key in object) {//只遍历本地属性if (object.hasOwnProperty(key)) {//相当于 block(object[key], key)block.call(context, object[key], key, object);}}};function print(el,index){alert(index : el)}forEach ([1, 2, 3], print);forEach ({a: aa, b: bb,c: cc}, print);forEach (司徒正美, print);forEach(document.styleSheets,function(el){if(el.href) alert(el.href)});代码function Person(name, age) {this.name name || ;this.age age || 0;};var fred new Person(Fred, 38);fred.language English;//极晚绑定fred.wife Wilma;//极晚绑定forEach(fred,print)完整代码function forEach(object, block, context, fn) {if (object null) return;if (!fn) {if (typeof object function object.call) {//遍历普通对象fn Function;} else if (typeof object.forEach function object.forEach ! arguments.callee) {//如果目标已经实现了forEach方法则使用它自己的forEach方法(如标准游览器的Array对象)object.forEach(block, context);return;} else if (typeof object.length number) {// 如果是类数组对象或IE的数组对象_Array_forEach(object, block, context);return;}}_Function_forEach(fn || Object, object, block, context);};function _Array_forEach(array, block, context) {if (array null) return;var i 0,length array.length;if (typeof array string)array array.split();for (;i length; i) {block.call(context, array[i], i, array);}};_Function_forEach function(fn, object, block, context) {// 这里的fn恒为Functionfor (var key in object) {//只遍历本地属性if (object.hasOwnProperty(key)) {//相当于 block(object[key], key)block.call(context, object[key], key, object);}}};function print(el,index){alert(index : el)}function Person(name, age) {this.name name || ;this.age age || 0;};var fred new Person(Fred, 38);fred.language English;//极晚绑定fred.wife Wilma;//极晚绑定forEach(fred,print)在Base2中还提供了一个叫unbind的方法我们可以用它把原生对象的forEach方法剥离出来供我们调用核心代码var _slice Array.prototype.slice;function unbind(fn) {return function(context) {return fn.apply(context, _slice.call(arguments, 1));};};完整代码try{var _slice Array.prototype.slice;function unbind(fn) {return function(context) {return fn.apply(context, _slice.call(arguments, 1));};};function print(el,index){alert(index : el)}var each unbind(Array.prototype[forEach])var a {cc : function(e){alert(e)}};each([11111,22222],a.cc,a)//最后的a可有可无}catch(e){alert(请在标准浏览器中使用)}这篇文章就介绍到这了希望大家以后多多支持脚本之家。
http://www.pierceye.com/news/736224/

相关文章:

  • 免费的黄冈网站有哪些平台游戏软件上海网站建设自学
  • 网站建设摊销几年wordpress怎样建立二级菜单
  • 营销方案案例北京搜索引擎优化seo专员
  • 网站建设是什么科目wordpress 火车头
  • 做网站需要什么专业方向的员工wordpress yeti
  • 网站建设项目登记表长沙建网站培训机构
  • 拖拽建站平台福州小学网站建设
  • 网站定制套餐建设企业网站需要注意的问题
  • 织梦贷款网站源码网页开发工具
  • 乐清官方网站建筑公司企业号
  • 代做网站的公司有哪些网红营销活动
  • 自己想开个网站怎么弄搜索热词排行榜
  • 智博常州网站建设wordpress缩略图只生成full
  • 化妆品网站模版免费下载网站空间的后台控制面板
  • 做外贸网站公司注册一个免费的网站吗
  • 网站开通申请wordpress图片分享
  • 提高网站性能网站建设中源代码
  • 海珠营销型网站建设公司山东城建建设职业学院教务网站
  • 怎样用虚拟主机建网站温州购物网络商城网站设计制作
  • 站外seo推广游戏模板 wordpress
  • 做翻译网站 知乎怎么制作网站主题
  • 照片书那个网站做的好重庆网站建设价格费用
  • 网站两侧广告石家庄建设
  • 网站设计的企业网站建设教程txt
  • 大型建站公司seo查询5118
  • 百度站长提交工具中小企业建站模板
  • 企业网站西安seo服务
  • 做网站需要多少个人网站logo设计
  • 新浪云 建设网站中企动力双语网站
  • 网站建设中心网站开发前端工程师