dom_pub.js

【dom_pub.js】// JavaScript Document
//DOM处理---开始----// add by sugy
//获取对象
function $(element)
{
if (document.getElementById)
{
return extend(document.getElementById(element),domMethod);
}
else if(document.all)
{
return extend(document.all[element],domMethod);
}
else
{
return null;
}
};
var domMethod = {//DOM扩展方法
css:function(_opation){
if(typeof(_opation)=="string"){
return this.style[_opation];
}else{
extend(this.style,_opation);
}
},
bg:function(_opation){
if(/^#.+/.test(_opation)){//背景色
this.style.backgroundColor = _opation;
}else{//背景图片
this.style.backgroundImage = "url("+_opation+")";
}
}
}
function extend(destination, source){//扩展对象
for (var property in source){
destination[property] = source[property];
}
return destination;
}
//DOM处理---结束----//

    推荐阅读