jquery中empty()是采用逐个移除子元素实现的
zepto中empty()是采用直接innerHtml=''实现的
一起来看一下:
zepto中empty()是采用直接innerHtml=''实现的
一起来看一下:
empty:function(){
var elem,i=0;
for(;(elem = this[i]) != null; i++) {
if(elem.nodeType === 1){
jQuery.cleanData(elem.getElementsByTagName("*"));
}
while(elem.firstchild){
elem.removeChild(elem.firstchild);
}
}
}
empty:function(){
return this.each(function(){
this.innerHtml=''
})
}