以image从同一文件夹index和javaScript文件都在,但由于某种原因,它不会加载。它给我的错误是,"Failed to load resource: the server responded with a status of 404 (Not Found)"var img = dcoument.createElement("IMG");img.height = 500;img.width = 340;img.src = '/img.jpg';document.getElementById("addImgHere").appendChild(img);
1 回答

ABOUTYOU
TA贡献1812条经验 获得超5个赞
你的代码工作得很好。
您的代码中有两个问题:
您已将图像路径指定为'/img.jpg'。它应该是'./img.jpg'
您在第 1 行拼错了 document。
不正确:
var img = dcoument.createElement("IMG");
正确的:
var img = document.createElement("IMG");
添加回答
举报
0/150
提交
取消