87,989
社区成员
发帖
与我相关
我的任务
分享
(function(){
var MN=function(ele){
if(!ele) return false;
ele=ele.split(/\s/);
var $=selector(ele);
function selector(ele){
return (ele.length==2)?document.getElementById(ele[0]).getElementsByTagName(ele[1]):document.getElementById(ele[0]);
}
return{
getOffset:function(){
var top=0,left=0;
while($!= null){
top+=$.offsetTop;
left+=$.offsetLeft;
$=$.offsetParent;
}
return {top:top,left:left};
},
opacity:function(v){
if(typeof v!='number') v=100;
if(!-[1,]) $.style.filter='alpha(opacity='+v+')';
$.style.MozOpacity=v/100;
$.style.opacity=v/100;
return this
},
html:function(v){
if(!v) return $.innerHTML;
$.innerHTML=v;
return this;
},
eq:function(v){
if(typeof v=='number') $=$[v];
return this;
}
}
}
window.$=MN;
})()
(function(){
var MN=function(selector){
return new MN.fn.init(selector);
}
MN.fn=MN.prototype={
init:function(selector){
if(selector){
selector=selector.split(' ');
this.$=(selector.length==2)?document.getElementById(selector[0]).getElementsByTagName(selector[1]):document.getElementById(selector[0]);
}
return this;
},
eq:function(v){
if(typeof v=='number') this.$=this.$[v];
return this;
},
getOffset:function(){
var top=0,left=0;
while(this.$!= null){
top+=this.$.offsetTop;
left+=this.$.offsetLeft;
this.$=this.$.offsetParent;
}
return {top:top,left:left};
},
html:function(v){
if(!v) return this.$.innerHTML;
this.$.innerHTML=v;
return this;
},
opacity:function(v){
if(typeof v!='number') v=100;
if(!-[1,]) this.$.style.filter='alpha(opacity='+v+')';
this.$.style.MozOpacity=v/100;
this.$.style.opacity=v/100;
return this;
},
extend:function(obj){
for(var i in obj){
this[i]=obj[i];
}
}
}
MN.fn.init.prototype=MN.fn;
window.$=MN;
})()
