Ok, lets say you are waiting for a image to load...
Your code would look something like this:
HTML Code:
<html>
<head>
<title>Page Name</title>
<style>
<!--
/** Your loading class **/
.loading{
background-image: url('images/loading.gif');
}
//-->
</style>
<script>
<!--
$(document).ready(function()
{
// Add loading class to box div
$('div#box').addClass('loading');
// Create the image
var myIMG = new Image();
$(myIMG).load(function()
{
// Hide the image
$(this).hide();
// Remove loading class
$('div#box').removeClass('loading');
// Show the image
$(this).show();
// Add the image to the box div..
$('div#box').html($(this));
}).attr('src','images/myIMG.jpg');
});
//-->
</script>
</head>
<body>
<div id="box"></div>
<!-- Other stuff here..................................... -->
</body>
</html>
Last edited by thehuskybear; 09-13-2008 at 11:07 PM..
|