第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

js 刪除元素報錯

js 刪除元素報錯

直接看代碼,msgList 是一個 ul 元素,target.parentNode 是 ul 下的 li,target 是 li 內(nèi)部的 a 標(biāo)簽,要實現(xiàn)的功能是在 ul 上設(shè)置了 click 的事件監(jiān)聽,當(dāng)點擊 a 的時候,通過事件冒泡,會刪除包含該 a 標(biāo)簽的 li 標(biāo)簽。但是如下的寫法最終該元素也刪除了,但是控制臺卻報了一個錯誤,沒想明白怎么回事,請大神指教一二。報的錯誤:但是我不使用事件委托的方式,直接遍歷所有的 a 標(biāo)簽,就是正常的。
查看完整描述

2 回答

?
米琪卡哇伊

TA貢獻(xiàn)1998條經(jīng)驗 獲得超6個贊

第一張圖里面使用 事件委托的方式,剛才執(zhí)行了一遍,也沒報錯,
看代碼也沒任何問題。應(yīng)該是其它地方出問題了。

查看完整回答
反對 回復(fù) 2019-03-05
?
蠱毒傳說

TA貢獻(xiàn)1895條經(jīng)驗 獲得超3個贊

MDN上有針對removeChild上可能造成的異常有解釋:

The method throws an exception in 2 different ways:

  • If the child was in fact a child of element and so existing on the
    DOM, but was removed the method throws the following exception:

Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

  • If the child doesn't exist on the DOM of the page, the method throws
    the following exception:

Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.

If child was in fact a child of element at the time of the call, but was removed by an event handler invoked in the course of trying to remove the element (eg, blur.)


查看完整回答
反對 回復(fù) 2019-03-05
  • 2 回答
  • 0 關(guān)注
  • 963 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號