I need to show a preloader image before append a huge image in the html body. In my script, a tooltip with a image is showed on a mouseover event only after it is complete loaded. The image takes too long to be completed. Meanwhile I want to show something on the page.
this.screenshotPreview = function(){
xOffset = 10;
yOffset = 30;
$('a.screenshot').hover(function(e){
this.t = this.title;
this.title = '';
var c = (this.t != '') ? '<br/>' + this.t : '';
$('body').append('<p id="screenshot"><img src="images/image.png" alt="Url preview" />'+ c +'</p>');
$('#screenshot')
.css('top',(e.pageY - xOffset) + 'px')
.css('left',(e.pageX + yOffset) + 'px')
.fadeIn('fast');
},
function(){
this.title = this.t;
$('#screenshot').remove();
});
$('a.screenshot').mousemove(function(e){
$('#screenshot')
.css('top',(e.pageY - xOffset) + 'px')
.css('left',(e.pageX + yOffset) + 'px');
});
};
// starting the script on page load
$(document).ready(function(){
screenshotPreview();
});
Thanks.
Please set preloader background image on this div #screenshot,
when this div appending , BG will show before showing IMG huge image