Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <img src="http://www.nicenicejpg.com/600" alt="">
  <img src="http://www.nicenicejpg.com/200" alt="">
  <img src="http://www.nicenicejpg.com/500" alt="">
  <img src="http://www.nicenicejpg.com/400" alt="">
  <img src="http://www.nicenicejpg.com/50" alt="">
</body>
</html>
 
.preloader {
  position: relative;
  display: inline-block;
}
.preloader .percent-loaded {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background-color: rgba(255, 0, 0, 0.5)
}
 
$('img').each(function () {
  
  var $img = $(this),
      $percentLoaded = $('<span class="percent-loaded">');
  
  $img.wrap('<span class="preloader">');
  
  $img.parent().append($percentLoaded);
  
  $img.on('load', function () {
    $percentLoaded.fadeOut(5000);
    $img.unwrap();
  });
  
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers