Add image element to DIV using JavaScript

Last Reply on Sep 21, 2018 03:02 AM By chetan

Posted on Sep 20, 2018 10:48 PM

Is it possible to call an image as a class and display it on page?


<div class="catimage"></div>


Posted on Sep 21, 2018 03:02 AM

kindly refer the below.

<script type="text/javascript">
        var elem = document.createElement("img");
        elem.setAttribute("src", "");
        elem.setAttribute("height", "768");
        elem.setAttribute("width", "1024");
        elem.setAttribute("alt", "Flower");
<div id="placehere">