jQuery HTML Element How to - Fade in Image Load








Question

We would like to know how to fade in Image Load.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-2.0.2.js'></script>
<style type='text/css'>
.fadein {<!--from   w  ww  .ja  v  a  2 s . com-->
  display: none;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $('.fadein').fadeIn(2500);
});
</script>
</head>
<body>
  <img src="http://www.java2s.com/style/download.png" class="fadein" />
</body>
</html>

The code above is rendered as follows: