[英]How to move the elem in javascript
I know Javascript in the beginning level and I need some help. 我知道初级Javascript,我需要一些帮助。
left = '-180px';
$sub_menu.show().animate({'left' : left}, 200);
I want to move $sub_menu from the right side to 180px
from his default position before animate it, ie to make the indent on the right. 我想在设置动画之前将$ sub_menu从右侧移动到默认位置
180px
,即在右侧进行缩进。
!!! ! EDIT !!!
编辑!!!
Here my jsfiddle 在这里我的jsfiddle
For each menu element, on mouseenter, I enlarge the image, and show both sdt_active
span and sdt_wrap
span. 对于每个菜单元素,在mouseenter上,我放大图像,并显示
sdt_active
span和sdt_wrap
span。 If the element has a sub menu
( sdt_box
), then I slide it - if the element is the last one in the menu I slide it to the left, otherwise to the right. 如果元素有一个
sub menu
( sdt_box
),那么我将其滑动 - 如果元素是菜单中的最后一个,我将其滑动到左侧,否则向右滑动。 My problem is the last Menu 6 . 我的问题是最后一个菜单6 。 It must work as other menus only it should slide to the left on the same width.
它必须像其他菜单一样工作,只应在相同的宽度上向左滑动。
我想你正在寻找这个:
$sub_menu.show().animate({ 'left' : '-=180px' }, 200)
use this 用这个
$sub_menu.css('left','-180px');
and for animation you can add CSS3 transition code to your CSS3 property 对于动画,您可以将CSS3过渡代码添加到CSS3属性中
check this http://api.jquery.com/animate/ 查看此http://api.jquery.com/animate/
and you should use this , in your example 你应该在你的例子中使用它
$sub_menu.show().animate({ 'left' : '-180px' }, 200);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.