JQUERY在图像变化时创建滑动效果(JQUERY Creating a sliding effect while image is changing)

编程入门 行业动态 更新时间:2024-10-24 02:37:30
JQUERY在图像变化时创建滑动效果(JQUERY Creating a sliding effect while image is changing)

我有三个图像1.jpg,2.jpg,3.jpg& <img id="add" src="1.jpg"></img>此图像的宽度,高度和位置根据需要设置和工作精细。 我已应用JQUERY淡入淡出属性在上面的图像之间切换,它也工作正常。

但我确切地想要图像以滑动方式改变,即1.jpg向左滑动并消失并在2.jpg中拖动其位置等等在特定间隔中继续。

希望我很清楚......

问候。

I have three images 1.jpg,2.jpg,3.jpg & <img id="add" src="1.jpg"></img> the width , Height & position of this image is set as required & working fine. I have applied JQUERY fade property to toggle between the above images & its also working fine.

But I want precisely that the images change in sliding fashion, i.e. 1.jpg slides left and vanishes and drags in 2.jpg in its position & so on continues in specific interval.

Hope I am clear...

Regards.

最满意答案

Yhank大家为你的努力,但是,我自己配置​​了...这是它的工作原理:

index.html的:

<html> <head> <script src="jquery.js"></script> <script src="slide.js"></script> </head> <body> <div > <img id="pic1" src="1.jpg"style="width:0px;height:120px;"/><img id="pic2" src="2.jpg" style="width:160px;height:120px;"/> </div> </body> </html>

slide.js

$("document").ready(function(){ var img_l=$("#pic1"); var img_r=$("#pic2"); setInterval(function(){ img_l.animate({width:'160px'},1000);; //animating the image t colapse img_r.animate({width:'0px'},1000);; //animating the image t expand var temp_var=img_l; //swaping values to revert previous action img_l=img_r; img_r=temp_var; },3000); //repeating the effect every 3 seconds });

这符合我的要求,并且在所有主流浏览器中具有完全相同的行为......谢谢。

Yhank You everyone for your efforts, But , I configured it myself... Here is how it worked:

index.html:

<html> <head> <script src="jquery.js"></script> <script src="slide.js"></script> </head> <body> <div > <img id="pic1" src="1.jpg"style="width:0px;height:120px;"/><img id="pic2" src="2.jpg" style="width:160px;height:120px;"/> </div> </body> </html>

slide.js

$("document").ready(function(){ var img_l=$("#pic1"); var img_r=$("#pic2"); setInterval(function(){ img_l.animate({width:'160px'},1000);; //animating the image t colapse img_r.animate({width:'0px'},1000);; //animating the image t expand var temp_var=img_l; //swaping values to revert previous action img_l=img_r; img_r=temp_var; },3000); //repeating the effect every 3 seconds });

This is doing well with my requirements and has exactly same behaviour within all leading browsers... Thanks.

更多推荐

本文发布于:2023-07-16 07:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   效果   Creating   JQUERY   image

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!