I have an image displaying using the jquery. When mouse over to that image, I like the mouse to change to be clickable and when clicked, I like to load another image. This is my code and not working. Any ideas?
html code:
jquery code:
$("#div1").click(function () {
var img_cpu = "http://192.168.101.1/cpu.png";
var myImage = new Image();
$(myImage).load(function () {
$("#div2").html(myImage)
}).error(function () {
$('#div2').hide();
})
.attr('src', img_cpu)
});
some issues occurred
you created a new imagevar myImage = new Image();but you didn’t specified asrclater (so load event never triggers)myImage32is not defined anywhere in your codefurthermore be sure that
cpu.png644) to be viewedcompleteproperty and trigger the handler defined for load event (see snippet below)