如何自动选择幻灯片图像中的中央图片? [英] How to auto select center picture in a slide images?
问题描述
你好.
我有使用 Jquery 和 jcarousellite 的幻灯片图像. a>.
您可以在此处
看到它
我要在幻灯片中自动选择中心图片(背景不同).现在,当我单击向右箭头时,它可以正常工作5次,在6-7次时,它工作不正确.而且,单击左箭头时,只有2次可以正常工作.
这是我的代码
首先,在IMG选项卡中-必须具有ID属性.之后,SPAN必须具有ID属性.
Hello.
I have slide-show images used Jquery and jcarousellite.
You can see it in here
I want to its auto select center picture( has difference background) in slide. Now, when I click on right arrow, it can work correct 5 times, on 6-7 times, it work incorrect. And more, when click on left arrow, only 2 times work correct.
This is my code
The firt, in IMG tab – It have to ID property. After that, SPAN have to ID property.
<DIV class="photo">
<IMG id="2" src="./Hexbal_files/1262155399heelgarde.png"
width="160" height="220" class="imgSlide" alt="Heelgarde">
</DIV>
在脚本代码中,我必须获取IMG标签的ID(例如2),然后使用javascript设置SPAN标签的类名称
In script code, I have to get ID of IMG tab (in example is 2) then using javascript to set class name for SPAN tag
<SCRIPT language="javascript" type="text/javascript">
$(".displayThumb").jCarouselLite({
btnNext: ".arowleft",
btnPrev: ".arowright",
visible:5,
beforeStart: function(a) {
var s = a[1].innerHTML; //get center picture
if(isLeft)
s=a[3].innerHTML;
var i=s.lastIndexOf("id="); //find id of img tag
if(i<0) return;
s = s.slice(i+3,i+7);
var array=s.split(" ",2) ;
s=array[0];
s=s.replace( /"/g, '' );//replace quote
document.getElementById('pro' + s).className='test_hover';//set new class name for span tag
}
});
</SCRIPT>
我不明白为什么.请帮我.这对我的项目非常重要.
非常感谢.
PS:对不起,我的英语.
我的昵称Y.H:trinhhoaithanh1905
电子邮件:hoaithanhtrinh@gmail.com
I don’t understand why that. Please help me. It’s very important in my project.
Thank so much.
PS : Sorry my English.
My nick Y.H :trinhhoaithanh1905
Email:hoaithanhtrinh@gmail.com
推荐答案
(" ).jCarouselLite({ btnNext:" , btnPrev:" , 可见: 5 , beforeStart:功能(a){ var s = a [ 1 ].innerHTML; // 获取中心图片 如果(isLeft) s = a [ 3 ].innerHTML; var i = s.lastIndexOf((span class ="code-string">" ); // 找到img标签的ID 如果(i< 0)返回; s = s.slice(i + 3,i + 7); var array = s.split(" , 2 ); s = array [ 0 ]; s = s.replace(/"
(".displayThumb").jCarouselLite({ btnNext: ".arowleft", btnPrev: ".arowright", visible:5, beforeStart: function(a) { var s = a[1].innerHTML; //get center picture if(isLeft) s=a[3].innerHTML; var i=s.lastIndexOf("id="); //find id of img tag if(i<0) return; s = s.slice(i+3,i+7); var array=s.split(" ",2) ; s=array[0]; s=s.replace( /"/g, '' );//replace quote document.getElementById('pro' + s).className='test_hover';//set new class name for span tag } }); </SCRIPT>
我不明白为什么.请帮我.这对我的项目非常重要.
非常感谢.
PS:对不起,我的英语.
我的昵称Y.H:trinhhoaithanh1905
电子邮件:hoaithanhtrinh@gmail.com
I don’t understand why that. Please help me. It’s very important in my project.
Thank so much.
PS : Sorry my English.
My nick Y.H :trinhhoaithanh1905
Email:hoaithanhtrinh@gmail.com
只需更改为以下代码:
Just changed to code bellow:
<script language="javascript" type="text/javascript">
(.displayThumb").jCarouselLite({ btnNext:.arowleft", btnPrev:.arowright", 可见:5 beforeStart:function(a){ a.find('span').removeClass('test_hover'); }, afterEnd:function(a){
(".displayThumb").jCarouselLite({ btnNext: ".arowleft", btnPrev: ".arowright", visible: 5, beforeStart: function(a) { a.find('span').removeClass('test_hover'); }, afterEnd: function(a) {
这篇关于如何自动选择幻灯片图像中的中央图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!