How to move an element in javascript

I know Javascript at an beginner level and I need help.

left = '-180px';
$sub_menu.show().animate({'left' : left}, 200);

      

I want to move $ sub_menu from the right side to 180px

from its default position before animating it, i.e. indent to the right.

!!! EDIT !!!

Here's my jsfiddle

For each menu item, in the center of the mouse, I zoom in and show both the sdt_active

span and sdt_wrap

span. If the element has sub menu

( sdt_box

), then I slide it - if the element is the last in the menu, I slide it to the left, otherwise to the right. My problem is the last Menu 6 . It should work like other menus, only it should slide to the left at the same width.

+3


source to share


3 answers


I think you are looking for this:



$sub_menu.show().animate({ 'left' : '-=180px' }, 200)

      

+2


source


use this

$sub_menu.css('left','-180px');

      



and for animation you can add CSS3 transition code to CSS3 property

0


source


check http://api.jquery.com/animate/

and you should use this in your example

 $sub_menu.show().animate({ 'left' : '-180px' }, 200);

      

0


source







All Articles