tags:

views:

63

answers:

3
+2  Q: 

div slide effect

i need to slide a div down and then up on an event, how can i do this in java script

+1  A: 

I would recommend that you check out jQuery/UI/Effects/Slide.

Andrew Hare
but i want to use it simply by javascript
vakas
There is no simple way to do it without using a library like jQuery. Using jQuery will actually make things very simple whereas rolling your own code to do this would be very complex in comparison.
Andrew Hare
@Andrew - I agree with your answer, but worth noting for slide up/down he doesn't need jQuery UI, just jQuery core will do.
Nick Craver
+3  A: 

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;
    })
});
Sarfraz
slideToggle() have to define?
vakas
@vakas: see my updated answer please.
Sarfraz
borother sorry to say, infact i have never used jquery before, do i need some spcial library to add,or any thing special else?
vakas
@vakas: yes brother, you need to download the jquery from here http://jquery.com/ and include in your page.
Sarfraz
i have added this<script type="text/javascript" src="JavaScript\jquery.js"> $(function(){ alert('hi'); $('#link').click(function(){ $('#hello').slideToggle(); return false; })}); </script> but nt wrking
vakas
@vakas: see the code of the example demo link i posted in my answer, you can use like that.
Sarfraz
thanx brother its wrking now, can u also plz tell me any method to shake the page, i want to prompt the user,dat something has happend.
vakas
A: 

Hey,

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.

Brian