-1
How to run code when an image used as background
is loaded?
I tried to :
$ ('#IDdaImagem').on('load', function () {
/ / 'Código parágrafo CARREGAR uma page / Conteúdo'
})
and does not work the image continues to be loaded after...
is a background image, and use a jQuery plugin to open in other resolutions, the backstretch, it uses a div with backstretch class, as I load this background image with 2mb before the content of the site?
I tested this and it works, but not in the element that I will give show, only in Alert.
<script>
$('.backstretch img').load(function() {
alert('done loading image');
$("#corpo").show();
});
</script>
This doesn’t work:
<script>
$ ('#IDdaImagem').on('load', function () { // no space
$("#corpo").show();
})
</script>
This works:
<script>
$ ('#IDdaImagem').on('load', function () { // no space
alert ('Test');
})
</script>
How is the element
#corpo
before the script runs? If your style is likedisplay: none
shall function; ifvisibility: hidden
, no (because they are different things).– mgibsonbr
Another thing: I saw your question "Load page only when image is loaded", I don’t know if this can be considered a duplicate of it or not. I’ll let the community decide...
– mgibsonbr