如何使用jQuery创建左右滑动效果
How can I use jQuery to create a left and right sliding effect?
我有以下jQuery代码片段:
var target1 = $('.div1');
var target2 = $('.div2');
target1.delay(1500).fadeIn();
target2.delay(3000).fadeIn();
// I want to use slide left here instead of .fadeIn()
与.fadeIn()
类似,是否有幻灯片左/右选项?
我也发现了这个,但我不确定如何实现它,或者如果它是正确的。
使用您发布的链接中的代码
包含所需的库(或使用本地副本):
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.effects.core.js"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.effects.slide.js"></script>
添加Javascript到你的页面:
jQuery.fn.extend({
slideRightShow: function(speed) {
return this.each(function() {
$(this).show('slide', {direction: 'right'}, +speed || 1000);
});
},
slideLeftHide: function(speed) {
return this.each(function() {
$(this).hide('slide', {direction: 'left'}, +speed || 1000);
});
},
slideRightHide: function(speed) {
return this.each(function() {
$(this).hide('slide', {direction: 'right'}, +speed || 1000);
});
},
slideLeftShow: function(speed) {
return this.each(function() {
$(this).show('slide', {direction: 'left'}, +speed || 1000);
});
}
});
我甚至添加了speed
参数,这样你就可以指定你想要它动画的速度。
从那以后,你可以这样写:
$("#element_id").slideRightShow();
演示:http://jsfiddle.net/EzP2q/1/
看!这就是你需要的!
不同方向的幻灯片元素
jQuery UI有一个slide
函数
查看文档
相关文章:
- 在指令控制器中使用$attrs时出现问题
- 如何使用jQuery自动打开页面上的所有链接
- 如何使用url加载程序在webpack中导入多个图像
- 使用左右控制循环图像
- 如何使用左右箭头键在元素之间导航
- jQuery.queue() 与使用回调函数完成某事有何不同
- 使用用于在同一函数中命名函数的变量名称有何意义
- 如何使用 javascript 将 Top:50% 转换为 Top:305px(左右)
- 为什么要使用 jQuery $(window).ready(),它与 $(window).load() 有何不同
- 我想使用jquery左右移动按钮
- 我需要移动按钮左右,然后再次使用jquery左右
- 根据语言的不同,使用jQuery在左右文本对齐之间切换
- 使用香草Javascript使用鼠标事件左右移动/滑动图像
- 手动调用模块与使用browserify动态调用模块有何不同?
- 如何使用jQuery创建左右滑动效果
- 使用左右箭头导航到rel=next和rel=prev页面
- 插入一个“;指针“;使用Javascript/jquery指向左右或前后的光标
- 使用Javascript左右摆动图像
- 左右轮播控件在使用平滑滚动锚标记时不起作用
- 在 JavaScript 中使用重排隐藏元素,它与 CSS 隐藏属性有何不同