Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Demo by roXon</title>
</head>
<body>
  
  
  <img class="alertSound" src="http://cdn.slidesharecdn.com/profile-photo-NATURE4EVER-96x96.jpg?1350611713" />
  <img class="alertSound" src="http://animated-desktop-background.com/wp-content/uploads/2012/06/free-animated-nature-backgrounds.jpg" />
  
  
</body>
</html>
 
$(function() {
  
    function imgIsLoaded() {
      
      var audio = new Audio('http://rpg.hamsterrepublic.com/wiki-images/3/3e/Heal8-Bit.ogg');
      var img = new Image().src = this;
      img.onload = function(){
        audio.play();
      };
      
    }
  
    $('img.alertSound').each(function() {
        if( this.complete ) {
            imgIsLoaded.call( this );
        } else {
            $(this).one('load', imgIsLoaded);
        }
    });
  
  
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers