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);
};
本文详细介绍了如何利用ZYC.dom.setAttr和ZYC.dom.setAttrs两个函数进行DOM元素属性设置,包括创建元素、设置属性等基本操作。通过示例代码展示了如何灵活运用这两个函数进行DOM操作。
1851

被折叠的 条评论
为什么被折叠?



