摘要: 一直在寻找有关jQuery性能优化方面的小窍门,能让我那臃肿的动态网页应用变得轻便些。找了很多文章后,我决定将最好最常用的一些优化性能的建议列出来。我也做了一个jQuery性能优化的简明样式表,你可以打印出来或者设为桌面背景。一、选择器性能优化建议1. 总是从#id选择器来继承这是jQuery选择器的一条黄金法则。jQuery选择一个元素最快的方法就是用ID来选择了。1$('#content').hide();或者从ID选择器继承来选择多个元素:1$('#content p').hide();2. 在class前面使用tagjQuery中第二快的选择器就是tag 阅读全文
posted @ 2013-12-06 08:52 一只帅蚂蚁 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 好久没有更新内容了,因为我正在学习新的技术,最近公司业务突然繁忙,又开始更新最近写的东西了。效果图如上。DOM: 上一页 下一页 共1/10页 到第页确定参数说明:data-current-page="1" 和 data-total-page="12",分别标示当前页和总的页数CSS:.module-pages-select{height:20px; line-height:20px;color:#999;}.module-pages-select span{border-radius:5px;-webkit-border-radius:display: 阅读全文
posted @ 2013-10-29 10:36 一只帅蚂蚁 阅读(1115) 评论(0) 推荐(0) 编辑
摘要: function animate(args){ //保存运动对象 this.animateTarget=args.obj; //保存运动的属性 this.animateProperty=args.property; //保存速度 this.animaterSpeed=args.speed||6; //保存回调函数 this.callBack=args.callBack||false; //初始化动画 this.initAnimate();};animate.prototype={ initAnimate:function(){ var _this=this,speed; window.cl.. 阅读全文
posted @ 2013-09-11 09:47 一只帅蚂蚁 阅读(299) 评论(0) 推荐(0) 编辑
摘要: DOM:2013-09-04 09:35:00JS: function PZ_JTimer(args) { //定义一个定时器 this.timer=null; //保存定时器对象 this.timerBox=args.timerBox; //保存定时器结束时的回调函数 this.callBack=args.callBack; //格式化当前的时间数组(也就是服务器返回的时间,为了避免本地计算机的时间不准确) this.currentTime=this.format(args.timerBox.attr("data-nowTime")); //格式化定时器开始的时间 th. 阅读全文
posted @ 2013-09-04 16:44 一只帅蚂蚁 阅读(265) 评论(0) 推荐(0) 编辑
摘要: CSS:.J_PZDialog_mask{ display:none;background:#000; opacity:0.3;filter:alpha(opacity=30);position:fixed;_position:absolute;left:0;top:0; z-index:9999;}.J_PZDialog{display:none;position:fixed;_position:absolute; padding:5px;border-radius:5px; background:#a4a2a3; z-index:10000;}.J_PZDialog_caption{hei 阅读全文
posted @ 2013-08-09 10:51 一只帅蚂蚁 阅读(1054) 评论(0) 推荐(0) 编辑
摘要: /**@跨浏览器事件绑定,删除方法@解决IE现代事件绑定几个问题@1,重复绑定同一个处理函数不能过滤@2,处理函数的执行顺序问题@3,处理函数内this的指向问题@4,事件对象的不统一问题(添加了常用的W3C事件对象)@添加方法:addEvent(obj,type,fn);@删除方法:removeEvent(obj,type,fn);@name:杨永,qq:377746756,call:18911082352*/function addEvent(obj,type,fn){ //w3c if(obj.addEventListener){ obj.addEventListener(type,f. 阅读全文
posted @ 2013-07-12 15:28 一只帅蚂蚁 阅读(631) 评论(0) 推荐(0) 编辑
摘要: DEMO:CSS:.poster{ position:relative;width:940px;height:300px;}.poster .poster-box{ position:relative; z-index:1;width:940px;height:280px; overflow:hid... 阅读全文
posted @ 2013-07-09 16:34 一只帅蚂蚁 阅读(434) 评论(0) 推荐(0) 编辑
摘要: 随着网络的发展,网速和机器速度的提高,越来越多的网站用到了丰富客户端技术。而现在Ajax则是最为流行的一种方式。JavaScript是一种解释型语言,所以能无法达到和C/Java之类的水平,限制了它能在客户端所做的事情,为了能改进他的性能,我想基于我以前给JavaScript做过的很多测试来谈谈自己的经验,希望能帮助大家改进自己的JavaScript脚本性能。语言层次方面 循环 循环是很常用的一个控制结构,大部分东西要依靠它来完成,在JavaScript中,我们可以使用for(;;),while(),for(in)三种循环,事实上,这三种循环中for(in)的效率极差,因为他需要查询散列键,只 阅读全文
posted @ 2013-07-08 17:15 一只帅蚂蚁 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 预览效果:CSS:.scrollbar{ margin:20px;width:300px;height:300px; background:#303030; color:#CCC;}.scrollbar-track{ float:right;height:300px;width:14px; background:#3C3C3C;}.scrollbar-handle{ background:#616161; height:80px; border-radius:7px; cursor:pointer;}.handle-hover{ background:#777;}.scrollbar-area 阅读全文
posted @ 2013-07-02 15:43 一只帅蚂蚁 阅读(788) 评论(0) 推荐(0) 编辑
摘要: CSS:body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}ol,ul{list-style:none; 阅读全文
posted @ 2013-07-01 11:01 一只帅蚂蚁 阅读(492) 评论(0) 推荐(0) 编辑