2014年7月26日
摘要: function getByClass( className, context) { var context = context || document; if( context.getElementsByClassName) { return context.getEle... 阅读全文
posted @ 2014-07-26 14:26 violinxliu 阅读(1301) 评论(0) 推荐(0) 编辑
  2014年7月23日
摘要: var b = { ua: function () { var u = navigator.userAgent, app = navigator.appVersion; return { trident: u.indexOf('Trident'... 阅读全文
posted @ 2014-07-23 10:02 violinxliu 阅读(222) 评论(0) 推荐(0) 编辑
  2014年7月22日
摘要: 先大概了解一下:事件委托(代理) : 利用的就是冒泡操作1.性能要好2.针对新创建的元素,直接可以拥有事件。所以有时候需要通过循环节点来绑定事件的话,那请用事件委托吧,这样性能更好哦,当然JQ里面本身就是有delegate,on这些方法了,但是原生的话,做一下兼容性处理就好了。主要以一个例子学习一下... 阅读全文
posted @ 2014-07-22 14:10 violinxliu 阅读(157) 评论(0) 推荐(0) 编辑
  2014年7月10日
摘要: //返回数组中的最小值function min(target){ return Math.min.apply(0,target); }//返回数组中的最大值 function max(target){ return Math.max.apply(0,target); ... 阅读全文
posted @ 2014-07-10 00:11 violinxliu 阅读(237) 评论(0) 推荐(0) 编辑
  2014年7月9日
摘要: function repeat(target,n){ return Array.prototype.join.call({length: n + 1} , target); }repeat('str',2);//输出strstr 阅读全文
posted @ 2014-07-09 23:29 violinxliu 阅读(278) 评论(0) 推荐(0) 编辑
  2014年7月8日
摘要: 主要是借助了原生slice的方法。 var arr = { 0:'1', 1:'2', 2:'3', length:3 }; function toArray(arr){ return [].slice.call... 阅读全文
posted @ 2014-07-08 23:52 violinxliu 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 以一个小球来回顾一下canvas的小知识吧,因为也有一段时间没怎么接触这玩意了。 来回跑动的小球 阅读全文
posted @ 2014-07-08 22:21 violinxliu 阅读(180) 评论(0) 推荐(0) 编辑
  2014年7月7日
摘要: 最近为了巩固一下原生的知识,然后拿了一个js小游戏来入手。主要也是为了学习和练手。js代码如下: 1 window.onload = function(){ 2 var oBtn = document.getElementById('gameBtn'); 3 oBtn.oncl... 阅读全文
posted @ 2014-07-07 21:47 violinxliu 阅读(1113) 评论(0) 推荐(0) 编辑
  2014年7月6日
摘要: 简单的拖拽,有超出边界界限的检测。 阅读全文
posted @ 2014-07-06 20:58 violinxliu 阅读(129) 评论(0) 推荐(0) 编辑
摘要: js如何检测两个对象是否碰撞,方法如下, 1 function isBump(obj1,obj2){ //碰撞检测 2 var L1 = obj1.offsetLeft; 3 var R1 = obj1.offsetLeft + obj1.offsetWidth; 4 va... 阅读全文
posted @ 2014-07-06 19:59 violinxliu 阅读(859) 评论(0) 推荐(0) 编辑