jQuery add image inside of div tag

前端 未结 6 2233
北荒
北荒 2020-11-29 18:02

I have a div tag

Where is the image?

I would like to add an image tag inside of the div

End re

6条回答
  •  爱一瞬间的悲伤
    2020-11-29 18:44

    If we want to change the content of

    tag whenever the function image()is called, we have to do like this:

    Javascript

    function image() {
        var img = document.createElement("IMG");
        img.src = "/images/img1.gif";
        $('#image').html(img); 
    }
    

    HTML

提交回复
热议问题