Display image through html image element object

javascript, jquery, jquery-events

Solution

Also you can do like this :

    function createImage(source) {
        var pastedImage = new Image();
        pastedImage.onload = function() {

 document.write('<br><br><br>Your image in canvas: <img src="'+pastedImage.src+'" height="100" width="200"/>');                      

        }
        pastedImage.src = source;        
    }​

Problem

I have the following code : ``` function createImage(source) { var pastedImage = new Image(); pastedImage.onload = function() { } pastedImage.src = source; } ``` The function `createImage` contain the source parameter which contain the source of an image. After that I created the object `pastedImage` of class `Image` and after alerting that I am getting the html image element object like `[object HTMLImageElement]`. My question is how I can display image into my html page using that object. I want to display it after `onload` function.

Original source