Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

XML
<DIV class="photo">
   <IMG id="2" src="./Hexbal_files/1262155399heelgarde.png" 
    width="160" height="220" class="imgSlide" alt="Heelgarde"> 
 </DIV>


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

HTML
<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>


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
Posted
Updated 5-Feb-10 11:24am
v4

Just changed to code bellow:
XML
<script language="javascript" type="text/javascript">
 $(".displayThumb").jCarouselLite({
         btnNext: ".arowleft",
         btnPrev: ".arowright",
         visible: 5,
         beforeStart: function(a) {
                        a.find('span').removeClass('test_hover');
                        },
                        afterEnd: function(a) {
                        $(a[2]).find('span').toggleClass('test_hover');
                        }

     });
</script>

 
Share this answer
 
I have an answer for this question. Thank :laugh:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900