我試圖為我的所有 li 元素分配一個刪除按鈕,我正在使用 appenChild() 方法,但它給了我一個錯誤:“appendChild 不是一個函數(shù)”。我不明白為什么會這樣。這是我的代碼:function createTrashes() { //button creation with icon var createButton = document.createElement("button"); createButton.classList.add("trashButtons"); //create icon var icon = document.createElement("i"); icon.classList.add("fa", "fa-trash"); //asignt icon to button createButton.appendChild(icon); //append button to all list elements var list = document.querySelectorAll("li"); list.appendChild(createButton);}createTrashes();
Javascript 錯誤 appendChild 不是函數(shù)
函數(shù)式編程
2023-06-15 17:35:37