Monday, March 5, 2012

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.

[sourcecode language="javascript"]
$(document).ready(function()
{
$('div#content').hide();
$('a#link').click(function()
{
$('div#content').show('slow');
});

});
[/sourcecode]

Using slideDown() to control the fall  of content

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

[sourcecode language="javascript"]
$(document).ready(function()
{
$('div#content').hide();
$('a#link').click(function()
{
$('div#content').slideDown('slow');
});

});
[/sourcecode]

Using fadeOut() to control the fading effect

[sourcecode language="javascript"]
<!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>


[/sourcecode]

No comments:

Post a Comment

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...