![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js
a_Little_pumpkin
这个作者很懒,什么都没留下…
展开
-
阻止js bubble事件
当父div与子div同时具有不同click事件时,为了防止dom冒泡,防止点击子div时触发两个事件,则需要在子div的click事件中阻止bubble事件的发生。代码如下。[code="js"]function cancelBubble(e){ if (e && e.stopPropagation) { // 非IE的情况 e.stopPropagatio...原创 2014-09-11 20:24:55 · 149 阅读 · 0 评论 -
js的prototype原型设计模式
1.js对象的继承方式使用prototype原型模式。2.js的方法可以分为以下三类:a.类方法b.对象方法c.原型方法[code="js"]function People(name){ this.name=name; //对象方法 this.Introduce=function(){ alert("My name is "+this.n...原创 2014-09-16 15:06:21 · 155 阅读 · 0 评论 -
从js数组中判断存在字符串和删除指定字符串
判断存在:[code="js"]function contains(arr, str) { var i = arr.length; // 从数组中判断str是否存在 while (i--) { if (arr[i] === str) { return true; } } return...原创 2014-12-03 10:24:25 · 1820 阅读 · 0 评论