Reputation: 2177
I am trying to show hidden div using animation,
The code i tried is,
$("#seconddiv").hide();
$("#seconddiv2").click(function(){
$("#seconddiv").animate( { "opacity": "show", "top":"1000px"} , "slow" );
});
Here div is appearing from no where. But i want to, make div to appear as if it is moving down from top.
The code not working is,
$("#seconddiv2").click(function(){
$("#seconddiv").show();
$("#seconddiv").animate({top:'250px'},"slow");
});
Since the div is hidden animate function is not working.
What changes do i need to make it work? please help Thanks
Upvotes: 0
Views: 141
Reputation: 887
$("#seconddiv2").click(function() {
$("#seconddiv").animate({"top": "-=50px"}, "slow");
});
Upvotes: 0
Reputation: 15309
You need to give your #seconddiv
a relative or absolute positioning.
#seconddiv {
position: relative;
}
Changing the top
on static
positioned elements has not effect.
Upvotes: 2