当前位置: 代码迷 >> Web前端 >> 创造Element对象create
  详细解决方案

创造Element对象create

热度:251   发布时间:2012-08-25 10:06:20.0
创建Element对象create

api的应用场景是:创建一个Element对象

?

关于ZYC.dom.g的资料:http://zhangyaochun.iteye.com/blog/1439262

?

关于ZYC.dom.setAttr的资料:http://zhangyaochun.iteye.com/blog/1461224

?

?

/*
*setAttrs-set the attribute value for the element with the key*
*@function*
*@param {string||HTMLElement} element*
*@param {Object} attributes just like collection --{size:sizeValue,disabled:"disabled"}*
*relay on ZYC.dom.setAttr*
*@return {HTMLElement}*
*/
ZYC.dom.setAttrs = function(element,attributes){
        element = ZYC.dom.g(element);
		for(var key in attributes){
                    ZYC.dom.setAttr(element,key,attributes[key]);
		}
        return element;	
};
?

?

?

?

?

/*
*create-create an element*
*@function*
*@param {string} tagName*
*@param {object} ops_attrs*
*relay on ZYC.dom.setAttrs*
*@return {HTMLElement}*
*/
ZYC.dom.create = function(tagName,ops_attrs){
   var el = document.createElement(tagName);
   return ZYC.dom.setAttrs(el,ops_attrs);
};
  相关解决方案