我尝试了一些代码..
function loadImages() {
var img = document.createElement("img");
img.src = "/images/answers/${record1.answer_id}.png";
img.id = "answer_id";
}
function removeFile(){
var elements = document.getElementsById('/images/answers/${record1.answer_id}.png').document.getElementsByTagName('img');
}
答案 0 :(得分:0)
试试这个:
var elements = document.getElementById("answer_id");
elements.parentNode.removeChild(elements);
在document.getElementsById('/images/answers/${record1.answer_id}.png')
中你试图使用'src'来获取元素,而getElementsById
必须是getElementById
答案 1 :(得分:0)
隐藏元素:
document.getElementById('answer_id').style.display = 'none';
完全删除
document.getElementById('answer_id').remove();