JQuery Cycle2 - 如何重命名类 [英] JQuery Cycle2 - How to rename class
问题描述
我使用JQuery滑块Cycle2: - http://jquery.malsup.com/cycle2
,并在同一页面上运行2个不同的幻灯片。一切正常,但幻灯片显示div类名称对于'循环幻灯片'都是常见的。如果我重命名它,幻灯片将无效。
我需要重命名其中一个幻灯片类,因为我有一个根据类名添加图像的功能,由于它们具有相同的名称,因此图像会添加到两个幻灯片中,而我只想要添加更多图像。
第一张幻灯片:
I use the JQuery slider Cycle2 :- http://jquery.malsup.com/cycle2
, and have 2 different slideshows running on the same page. Everything is working fine but the slideshow div class name is common for both i.e. 'cycle-slideshow'. If I rename it the slideshow won't work.
I need to rename one of the slideshows class as I have a function that add images according to the class name, since they have got both same name the images are added on both slideshows while I only want one to have more images added.
1st slideshow :
<div class="cycle-slideshow"
data-cycle-fx=scrollHorz
data-cycle-timeout=1500
data-cycle-center-horz=true
data-cycle-center-vert=true
>
<img src="./upload/003.gif">
<img src="./upload/005.gif">
</div>
第二张幻灯片
2nd slide show
<div class="cycle-slideshow"
data-cycle-fx="fadeOut"
data-cycle-pause-on-hover="true"
data-cycle-speed="500"
data-cycle-timeout="7500"
data-cycle-auto-height="false"
>
<img src="./assets/images/title_image1.jpg" >
<img src="./assets/images/title_image2.jpg">
<img src="./assets/images/title_image3.jpg">
<img src="./assets/images/title_image4.jpg">
<img src="./assets/images/title_image14.jpg"/>
</div>
<button önclick="c()">Add more images</button>
添加图片的功能: -
function to add images:-
<script>
var images = [
'<img src="./assets/images/title_image6.jpg">',
'<img src="./assets/images/title_image7.jpg">',
'<img src="./assets/images/title_image8.jpg">'
];
function c() {
for (var i=0; i < images.length; i++) {
$('.cycle-slideshow').cycle('add', images[i]);
}
$(this).prop('disabled', true)
}
</script>
推荐答案
(' .cycle-slideshow')。cycle(' add',images [i]);
}
('.cycle-slideshow').cycle('add', images[i]); }
( this )。prop('' 已禁用', true )
}
< / script>
(this).prop('disabled', true) } </script>
问题在于
这篇关于JQuery Cycle2 - 如何重命名类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!