What is the best JavaScript code to create an img element

前端 未结 11 1986
攒了一身酷
攒了一身酷 2020-11-28 20:46

I want to create a simple bit of JS code that creates an image element in the background and doesn\'t display anything. The image element will call a tracking URL (such as

11条回答
  •  眼角桃花
    2020-11-28 21:24

    Just for the sake of completeness, I would suggest using the InnerHTML way as well - even though I would not call it the best way...

    document.getElementById("image-holder").innerHTML = "The Image";
    

    By the way, innerHTML is not that bad

提交回复
热议问题