0

我尝试了一些代码..

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');
}
4

2 回答 2

0

尝试这个 :

var elements = document.getElementById("answer_id");
elements.parentNode.removeChild(elements);

document.getElementsById('/images/answers/${record1.answer_id}.png')你试图使用它的'src'来获取元素并且getElementsById必须是getElementById

于 2013-10-25T07:05:03.403 回答
0

要隐藏元素:

document.getElementById('answer_id').style.display = 'none';

完全删除它

document.getElementById('answer_id').remove();
于 2013-10-25T07:05:05.893 回答