今年纯粹是JS学习年,一年大部分时间都在折腾JS,其它后台技术基本没有大的收获...
在学习JS的过程中得到了很多大哥的帮助,让我从JS菜鸟到现在的水平,对JS闭包的疑惑到现在的了解,对我帮助最大的是ALZ老大,小夜,UCREN开发者[小黄],阿旭,天凡,心跳,小白,中山,老白等等....
关于之前的一系列回帖,竟然被大家集体投成新手帖,看来是我太肤浅了... 以后不再写这种新手贴了,源代码全部删除,留下了一个PDF文档,之前发出的代码全部在里面,后期更新的__init_xu 色色js代码库不再在博客上贴出,请见谅!!!
新上传 __xu_init.all.min.js 最新版本的编译版本,支持MD5加密,提供xu.uid()生成唯一值
eo对象新增empty方法,呵呵,循环删除节点就可以了:
while ( this.ele.firstChild )
this.ele.removeChild( this.ele.firstChild );
/** * xu.dom.EObject */ xu._class.create('xu.dom','EObject',null,{ id: null , desc: 'DOM Element Object 封装器' , offset: function(){ if (!this.ele) return null ; var ele = this.ele ; var t=ele.offsetTop; var l=ele.offsetLeft; while(ele=ele.offsetParent){ t+=ele.offsetTop+(xu.browser.$IE ?ele.clientTop:0); l+=ele.offsetLeft+(xu.browser.$IE ?ele.clientLeft:0); } return {left:l,top:t}; } , attr: function(o){ if(!xu.verify._undef(o) && xu.verify._obj(o) && this.ele.setAttribute){ for(var p in o){ if (xu.verify._str(p)){ try { this.ele.setAttribute(p,o[p]) ; }catch(e){ debug_msg(this.ele.nodeName+" "+p+" 只读"); } } } } return this ; } , getAttr: function(name){ if ( name && this.hasAttr(name)) return this.ele.getAttribute(name); } , hasAttr: function(name){ if ( this.ele && this.ele.hasAttribute) return this.ele.hasAttribute(name); } , removeAttr: function(name){ if ( this.hasAttr(name)&&this.ele.removeAttribute ) this.ele.removeAttribute(name); return this ; } , setWidth: function(){} , setHeight: function(){} , setLeft: function(){} , setTop: function(){} , setPosition: function(){} , show: function(){ return this.css({display: ''}); } , hide: function(){ return this.css({display: 'none'}); } , /** * CSS 属性设置,支持{ color: "blue", 'background-color': "red" } * 依赖core.js * @param {} o * @return xu.dom.EObject */ css: function(o){ if (!xu.verify._undef(o) && xu.verify._obj(o)){ for(var p in o){ if (xu.verify._str(p)){ this.ele.style[p.getCamelcaseStyle()] = o[p] ; } } } return this ; } , getCss: function(name){ if (!xu.verify._undef(name) && xu.verify._str(name)){ return this.ele.style[name.getCamelcaseStyle()] ; } } , hasClass: function(cls_n){ var is = false; xu.array.each(this.ele.className.split(' '),function(item){ if (item == cls_n) is = true; }); return is; } , addClass: function(cls_n){ this.ele.removeClass(cls_n); this.ele.className += ' ' + cls_n; } , toggleClass: function(cls_n){ if (this.hasClass(cls_n)) this.removeClass(cls_n); else this.addClass(cls_n); } , removeClass: function(cls_n){ var new_cls_n = ''; xu.array.each(this.ele.className.split(' '),function(item){ if (item != cls_n){ if (i > 0) new_cls_n += ' '; new_cls_n += item; } }); this.ele.className = new_cls_n; } , // html: function(v){//在browser.ie.js中做了修正 if(v != undefined){ this.empty().ele.innerHTML = v.replace(/