troubleshooting Question

jQuery: Remove each image after it loads

Avatar of skij
skijFlag for Canada asked on
6 Comments3 Solutions158 ViewsLast Modified:
After the image loads, I want to remove it.  This does NOT work:
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<style type="text/css">
img {
width: 100px;
<script type="text/javascript" src=""></script>
<script type="text/javascript">

$(document).ready(function() {

    var imgI=0;
    $('.showImage img').each(function() {
        var tmpImg = new Image() ;
        tmpImg.onload = function(){


         if( imgI++ === ($('.showImage img').length-1) ) {
          alert('all images loaded!');
        tmpImg.src = $(this).attr('src');
    }) ;
}) ;



 <div class="showImage"><img src="*?z2z2322z" alt=""/></div>
 <div class="showImage"><img src="" alt=""/></div>
 <div class="showImage"><img src="" alt=""/></div>

Join our community to see this answer!
Unlock 3 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros