api的使用场景:我们获取目标元素的直接子元素。
关于ZYC.dom.g请看这里:http://zhangyaochun.iteye.com/blog/1439262
注意:
1、思路主要还是循环-从目标元素的firstChild开始,直到本身和nextSibling一样的时候停止循环,返回一个数组
2、nodeType的判断 元素1
/*
*children --get the children element list for the target element*
*@function*
*@param {HTMLElement|String} element*
*@return {Array} if has no children return []*
*/
ZYC.dom.children = function(element){
element = ZYC.dom.g(element);
for(var children =[],el = element.firstChild;el;el = el.nextSibling){
if(el.nodeType == 1){
children[children.length] = el;
}
}
return children;
};
本文详细介绍了如何使用ZYC.dom.children API来获取指定元素的直接子元素,并提供了示例代码和注意事项。
744

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



