Reputation: 15
I want to show a animation to my div control.
When page is load div should be hidden , when user click a button div should appear with some animation I want to show a sliding animation on my div control, this should happen if a button is click.
I have to do it in jquery.
Upvotes: 0
Views: 263
Reputation: 22076
$(document).ready(function(){
$("#btn").click(function(){
$(".divClass").slideToggle("slow");
});
});
other options are slideDown, slideUp, slideToggle,fadeIn, fadeOut, fadeTo
A complete example is as follow
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn").click(function(){
$(".divClass").slideToggle("slow");
});
});
</script>
<style type="text/css">
.divClass
{
margin:0px;
padding:5px;
text-align:center;
background:#e5eecc;
border:solid 1px #c3c3c3;
height:120px;
display:none;
}
</style>
</head>
<body>
<div class="divClass">
<p>This is a sample JQuery Animation</p>
<p>Your text or control goes here...Your text or control goes here....Your text or control goes here</p>
</div>
<input id="btn" type="button" value="Show Div" />
</body>
</html>
Upvotes: 1