You can improve the code by adding a loading.gif
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>How to add table rows using jQuery</title>
<style>
.thumb{vertical-align:top; padding:2px; border:1px #CCC solid;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".image").click(function() {
//$('#main').hide();
var image = $(this).attr("href");
$('#main').attr("src", image);
$('#main').load(function() {
$('#main').fadeIn('slow');
});
return false;
});
});
</script>
</head>
<body>
<a href="images/image1.jpg" class="image"><img alt="Image1" src="thumb/image1.jpg" class="thumb" border="0"/></a>
<a href="images/image2.jpg" class="image"><img alt="Image2" src="thumb/image2.jpg" class="thumb" border="0"/></a>
<a href="images/image3.jpg" class="image"><img alt="Image3" src="thumb/image3.jpg" class="thumb" border="0"/></a>
<a href="images/image4.jpg" class="image"><img alt="Image4" src="thumb/image4.jpg" class="thumb" border="0"/></a>
<div id="container" style="height:400px; padding-top:20px;"><img id="main" src="images/image1.jpg" /></div>
</body>
</html>
View Demo
No comments:
Post a Comment