in my last posts i really enjoyed for ur good response , today am going to post on ANIMATE() .this is very interesting to do web projects..
JQUERY PART-1 (INSTALLATION , fadeIn(),fadeOut(),slideToggle())LAST POSTS ARE:
animation with animation() event:
while clicking the animate block1 button it calls block1 when we
press animate block2 button it calls block2 when we are going to
reset it uses $(selector).css() function
LIVE DEMO
<html>
<head>
<style>
div {
background-color:#bca;
width:200px;
height:1.1em;
text-align:center;
border:2px solid green;
margin:3px;
font-size:14px;
}
button {
font-size:14px;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<button id="go1">» Animate Block1</button>
<button id="go2">» Animate Block2</button>
<button id="go3">» Animate Both</button>
<button id="go4">» Reset</button>
<div id="block1">Block1</div>
<div id="block2">Block2</div>
<script>
$( "#go1" ).click(function(){
$( "#block1" ).animate( { width: "30%" }, 200)
.animate({ fontSize: "24px" }, 1500 )
.animate({ borderRightWidth: "15px" }, 1500 );
});
$( "#go2" ).click(function(){
$( "#block2" ).animate({ width: "90%" }, 1000 )
.animate({ fontSize: "24px" }, 1000 )
.animate({ borderLeftWidth: "15px" }, 1000 );
});
$( "#go3" ).click(function(){
$( "#go1" ).add( "#go2" ).click();
});
$( "#go4" ).click(function(){
$( "div" ).css({ width: "", fontSize: "", borderWidth: "" });
});
</script>
</body>
</html>
CHANGE BACKGROUND COLOR ON HOVER :
please download first CILCK HERE (jquery.color.js)
for this i am going to use jquery.color.js after
$(selector).hover(function()) and $(this).animate() enjoy this..
<style>
#div
{
background:#333333;
width:500px;
broder:1px;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" src="jquery.color.js"></script>
<script type="text/javascript">
$(function()
{
$('#div').hover(function()
{
$(this).animate({
"backgroundColor":"#bdbdbd",
},5000);
});
});
</script>
<div id="div">
this is siddhu
</div>
play with Mouseover() and Mouseout() Events:
same as above exmaple but o mouse over and out it will be animate
this is siddhu
<style>
#div
{
background-color:#eeeeee;
border:solid 3px #9900cc;
height:160px;
font-size:46px;
font-weight:bold;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" src="jquery.color.js"></script>
<script type="text/javascript">
$(function()
{
$('#div').mouseover(function()
{
$(this).animate({
"backgroundColor":"#bdbdbd",
"borderBottomWidth":"10px",
"borderBottomColor":"green"
},1000);
}).mouseout(function()
{
$(this).animate({
"backgroundColor":"#333333",
"borderBottomWidth":"3px"
},1000);
});
});
</script>
<div id="div">
this is siddhu
</div>
0 comments:
Post a Comment