tags:

views:

172

answers:

3

sliding div using javascript

i have three div with some content. i need the div to be moved one after another . moving div horizontally

any idea..

+3  A: 

You shall have to set position=absolute and then set x and y for the div. You can change their x and y inside a javascript. There are plenty of available scripts for sliding.

Kangkan
A: 

You could use jQuery and the slideDown() and slideUp() functions. See http://api.jquery.com/category/effects/sliding/

Dan Diplo
+1  A: 

Could be done like this:

// Moving the element to the 200 x 200 coordinate relative to
// the parent element, WITHOUT JQUERY

var elementStyles = document.getElementById("someDiv").style;
elementStyles.position = "absolute";
elementStyles.top = 200 + "px";
elementStyles.left = 200 + "px";

// Moving the element to the 200 x 200 coordinate relative to
// the parent element, WITH JQUERY

$("#someDiv").animate({
    top: 200 + "px",
    left: 200 + "px"
});

// If the position should be changed relative to the current position,
// add a `"+=" +` in front of `200` in the jQuery script, like this:

left: "+=" + 200 + "px"
Sune Rasmussen