0

I'm trying to make it so when a picture is not yet loaded it will add an icon on top of the image.

Here's what I have done, I can't really say anything else that it is not doing what it is supposed to do so.

$(".loading").show();

$(".img").load(function(){

    $(".loading").hide();
});

Index:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>

EDIT:

Apparently i made it work by rewriting my jQuery code:

$(function() {
    $(".loading").show();

    $('.img').on('load', function(){
        $(this).parent().parent().find(".loading").hide();
    });
});
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Athax
  • 200
  • 1
  • 12

0 Answers0