i need to slide a div down and then up on an event, how can i do 开发者_开发问答this in java script
Update I created this demo for you :)
You can do that easily with slideToggle() function of JQuery:
<div id="hello">Hello World</div>
<a href="#" id="link">Toggle Div</a>
JQuery:
$(function(){
$('#link').click(function(){
$('#hello').slideToggle();
return false;
})
});
I would recommend that you check out jQuery/UI/Effects/Slide.
Highly recommend look at what JQuery or another javascript library does, (maybe even AJAX control toolkit for .NET, which has JS components) and examine the JS file, and replicate the feature yourself...
I will say it probably isn't that easy to replicate yourself, meaning that the logic is pretty complex.
HTH.
精彩评论