jq 多个div从右向左依次显示_Jquery循环插件 - 从一个脚本循环插件多个div?

Im new to jquery/javascript and need help!

I want to use the cycle plugin in multiple divs with different images in each div. Each div is the same size and each image is the same size.

The code I have used so far shows all images in the first div but when I click on my logo (which is linked to index.html) all the images suddenly appear in place and working with the cycle plugin.

This is what I have in the head

$(document).ready(function(){

$('#box1').cycle({

fx: 'fade',

speed: 300,

timeout: 0,

next: '#box1',

pause: 1

});

});

$(document).ready(function(){

$('#box2').cycle({

fx: 'fade',

speed: 300,

timeout: 0,

next: '#box2',

pause: 1

});

});

$(document).ready(function(){

$('#box3').cycle({

fx: 'fade',

speed: 300,

timeout: 0,

next: '#box3',

pause: 1

});

});

body...

images/car.jpg

images/van.jpg

images/bottle.jpg

images/pattern.jpg

images/car.jpg

images/van.jpg

In the css the container is position: absolute;

I'm sure there is a simple solution but I have searched stackoverflow and other sites to no avail. Any help is greatly appreciated!!!!

解决方案

I made this example:

$(function() {

$('.box').each(function() {

var $this = $(this);

$this.cycle({

fx: 'fade',

speed: 300,

timeout: 0,

next: $this,

pause: 1

});

});

});​

it works as expected, yours too. May be you use too old jquery ? (current is 1.8)

if answer not fit your problem, can you please edit jsfiddle to show where the problem ?

when I load the page

when I click on my logo, linked to index.html

I think when you load the page you load not index.html, but index.htm, or index.php or something else, check your site directory

The jsfiddle should repeat your problem, not just show your structure

if your site on the internet - give me link and i will check

Try to change your code to the following:

$(document).load(function() {

$('.box').each(function() {

var $this = $(this);

$this.cycle({

fx: 'fade',

speed: 300,

timeout: 0,

next: $this,

pause: 1

});

});

});​

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值