function child(parent) {? ? ? ? ? ? var childlist = Array.of(parent.childNodes);//獲取父元素下的所有自己并轉為數組????????????//使用filter過濾? ? ? ? ? ? var listChild=childlist.filter(function (item, index, arr) {? ? ? ? ? ? ? ? return(item.nodeType==1);//返回所有nodeType==1的子集,但是可以獲取所有的item? ? ? ? ? ? })? ? ? ? ? ? console.log(listChild)//這里返回空[]? ? ? ? }? ? ? ? child(list)//傳入父元素
數組迭代方法filter里為何查不到nodeType
我要去幼兒園深造了
2017-10-21 11:31:04