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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

附加圖像到 div 未顯示

附加圖像到 div 未顯示

森林海 2024-01-18 15:44:33
我試圖通過創(chuàng)建一個(gè)新的 div 來打印 img,然后將其附加到圖像,但圖像沒有顯示。JS 這里 rpsGame 是主函數(shù),調(diào)用了 rpsFrontEnd 函數(shù),并且 rpsFrontEnd 的參數(shù)是正確的。function rpsGame(yourChoice) {    var humanChoice = yourChoice.id;    var botChoice = noToChoice(randTorpsInt());      console.log("bot choice " + botChoice);    console.log("your choice " + humanChoice);    var results = decideWinner(humanChoice, botChoice);    console.log(results);    var message = finalMessage(results);    console.log(message);    rpsFrontEnd(humanChoice, botChoice, message);}這個(gè) rpsFrontend 首先刪除所有圖像,然后創(chuàng)建一個(gè)新的 div 并在其中附加一個(gè) img,但 img 沒有被打印function rpsFrontEnd(humanImageChoice, botImageChoice, finalMessage) {    var imageDatabase = {        "rock": document.getElementById("rock").src,        "paper": document.getElementById("paper").src,        "scissor": document.getElementById("scissor").src    }    document.getElementById("rock").remove();    document.getElementById("paper").remove();    document.getElementById("scissor").remove();    var humanDiv = document.createElement("div");    var botDiv = document.createElement("div");    var messageDiv = document.createElement("div");        humanDiv.innerHTML="<img src'"+imageDatabase[humanImageChoice]+"'>";    console.log(humanDiv);    document.getElementById("col").appendChild(humanDiv);}謝謝你的時(shí)間!
查看完整描述

2 回答

?
哈士奇WWW

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

一小時(shí)后我得到答案非常小的錯(cuò)誤

humanDiv.innerHTML="<img src='"+imageDatabase[humanImageChoice]+"'>";

再次感謝那些在這里付出時(shí)間的人,innerHtml 中再次缺少等號(hào)


查看完整回答
反對(duì) 回復(fù) 2024-01-18
?
小怪獸愛吃肉

TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超1個(gè)贊

document.getElementById("row").appendChild(humanDiv);

此行不起作用,因?yàn)?HTML 中沒有包含 ID 行的元素 - 它是一個(gè)類,因此 getElementById 找不到它。

改變這個(gè)

<div class="row">

對(duì)此

<div id="row">


查看完整回答
反對(duì) 回復(fù) 2024-01-18
  • 2 回答
  • 0 關(guān)注
  • 156 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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