创建Element对象create
api的应用场景是:创建一个Element对象
/* *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); };