亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

數組迭代方法filter里為何查不到nodeType

數組迭代方法filter里為何查不到nodeType

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)//傳入父元素
查看完整描述

1 回答

已采納
?
QuoVadis

TA貢獻4條經驗 獲得超2個贊

var?childlist?=?Array.of(...parent.childNodes);
或者
var?childlist?=?Array.from(parent.childNodes);


查看完整回答
反對 回復 2017-10-21
  • 1 回答
  • 0 關注
  • 1046 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號