Java的新手。這是一個類似程序的抽認卡,應該包含圖像,然后您猜出它的名稱。我正在使用setAttribute,但是圖像沒有填充頁面。我應該為它選擇一個圖像進行for循環還是只是做我所做的事情?我需要使用setAttribute,但我仍然堅持為什么圖像不會填充。非常感謝您的幫助。function populateImages() { var newDiv = document.createElement('div'); newDiv.setAttribute('class', 'frame'); newDiv.setAttribute('src', personArray.url); newDiv.setAttribute('onclick', 'promptForName(this)'); newDiv.setAttribute('onmouseover', 'styleIt(this)'); newDiv.setAttribute('onmouseout', 'unStyleIt(this)'); newDiv.setAttribute('id', '1'); document.getElementById('pic-grid').appendChild(newDiv);}
使用對象將setAttribute轉換為img
肥皂起泡泡
2021-04-09 10:14:13