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.
Hiya : Working demo http://jsfiddle.net/wXV3u/
Api used = .html
http://api.jquery.com/html/
In demo click on the click me
button.
Hope this helps! Please lemme know if I missed anything! B-)
Code
$('#foo').click(function() {
createImage("http://images.wikia.com/maditsmadfunny/images/5/54/Hulk-from-the-movie.jpg");
});
function createImage(source) {
var pastedImage = new Image();
pastedImage.onload = function() {
}
pastedImage.src = source;
$(".testimonialhulk").html(pastedImage);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With