jQuery Style How to - Load background image with delay








Question

We would like to know how to load background image with delay.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-git.js'></script>
<script type='text/javascript'>
       $('document').ready(function(){
            setTimeout(function() {<!--  w w w  . j  a v  a2 s .c om-->
                $('body').css('background-image','url(http://www.java2s.com/style/download.png)');
            },1000);
        });

</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: