RSS

Tag Archives: j

code zone jQuery Crash Course – Day 2 | Introduction to animation basics

It ‘s very easy to add some animation in jQuery. You only need to change the code a little bit. Some code snippets are listed below to understand animation basics in jQuery.

$(document).ready(function()
{
$('div#content').hide();
$('a#link').click(function()
{
$('div#content').show('slow');
});

});

Using slideDown() to control the fallĀ  of content

This will cause to fall the content inside the div as a drop down content.

$(document).ready(function()
{
$('div#content').hide();
$('a#link').click(function()
{
$('div#content').slideDown('slow');
});

});

Using fadeOut() to control the fading effect

<!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>Untitled Document</title>
<style type="text/css">
#content
{
background-color:#00F;
width:300px;
height:200px;
}
</style>
<script type="text/javascript" src="jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function()
{

$('a#link').click(function()
{
$('div#content').fadeOut('slow');
});


});
</script>
</head>

<body>
<a href="#" id="link">Click Me</a>
<div id="content">
</div>
</body>
</html>


 
Leave a comment

Posted by on March 5, 2012 in jQuery

 

Tags: , ,