// 创建元素
function cEle(oParent,attr,tag){
var node = document.createElement(tag||'div');
if(oParent){
cAppend(oParent,node);
}
if(attr){
cSetAttr(node,attr);
}
return node;
}
// 添加子元素
function cAppend(oParent,obj){
oParent.appendChild(obj);
}
// 添加样式
function cSetAttr(obj,attr){
for(var i in attr){
if(i=='id'){
obj[i] = attr[i];
}else{
obj.style[i] = attr[i];
}
}
}
// 添加内容
function cHtml(obj,str){
obj.innerHTML = str;
}
myJs
最新推荐文章于 2022-08-06 21:44:26 发布