jQuery add image inside of div tag

前端 未结 6 2231
北荒
北荒 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:35

    In addition to Manjeet Kumar's post (he didn't have the declaration)

    var image = document.createElement("IMG");
    image.alt = "Alt information for image";
    image.setAttribute('class', 'photo');
    image.src="/images/abc.jpg";
    $(#TheDiv).html(image);
    

提交回复
热议问题