Opacity defines to which extent make elements hidden. It ranges from 0 to 1. Where 0 make elements hidden and 1 completely visible. Below example shows how to use opacity in animate() method of jquery.
The opacity parameter is used inside CSS properties area.
Experience this example online
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<!DOCTYPE html>
<head>
<title>jQuery Animate</title>
<script src=“http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”></script>
<script type=“text/javascript” language=“javascript”>
$(document).ready(function() {
$(“#animate_button”).click(function() {
$(“.animate_spec”).animate({width: ‘500’,opacity:‘0.8’},“slow”);
$(“.animate_spec”).animate({height:‘300’,opacity:‘0.5’},“slow”);
});
});
</script>
<style type=”text/css”>
.animate_spec {
background-color:#bbaa00;
width:270px;
height:150px;
}
</style>
</head>
<body>
<button id=“animate_button”>Animate for height and width with opacity</button></button>
<div class=“animate_spec”>Example of animation for height and width with jquery animate() queue</div>
</body>
</html>
|
Also see jquery animate
Leave A Comment?