📌  相关文章
📜  document.getElementByClassName("preview").innerHTML=src; - HTML代码示例

📅  最后修改于: 2022-03-11 14:52:54.037000             🧑  作者: Mango

代码示例1
function update(previewPic){
/* In this function I should 
    1) change the URL for the background image of the div with the id = "image" 
    to the source file of the preview image

    2) Change the text of the div with the id = "image" 
    to the alt text of the preview image 
    */
   document.getElementById("image").setAttribute('style', 'background-image: url(' +  previewPic.getAttribute("src") + ')');
   document.getElementById("image").innerHTML = previewPic.getAttribute("alt");
}


function undo(){
    document.getElementById("image").style.backgroundImage = "";
    document.getElementById("image").title = "";
}