Solved

show cpations in sequence

Posted on 2012-03-29
4
165 Views
Last Modified: 2012-04-08
Hello Experts,

This was a solution by an expert here in expert exchange :-)
The script was for two caption running in a sequence. Now i need to add a third caption but it does not seem to work right. Can you please help?

$(function() {
     $("#captions div:first").hide();
     setInterval("SwapCaption()", 10000);
});
function SwapCaption()
{
    $("#captions>div").fadeToggle('slow', "linear");
	}

Open in new window

0
Comment
Question by:Refael
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Lalit Chandra
Comment Utility
Can you provide the full code of your page ? it will be easier for us to know.
0
 

Author Comment

by:Refael
Comment Utility
Hi Lalit-Chandra, it was your solution :-)

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27650586.html

I Simply need to add one more caption. I tried but there is a problem...
0
 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 500 total points
Comment Utility
yes,there is problem with the script. it will only run for 2 caption.
But now, below script can handle any number of caption.

Please replace the following script code  with mine previous code

<script>

$(function() {
$("#divImage-Slide>div").hide();
 currentDivToken = 0;
 maxDivCaptionToken = $("#divImage-Slide>div").length -1;
setInterval("SwapImageWithCaption()", 1000);
     
});
function SwapImageWithCaption()
{
$("#divImage-Slide>div").hide();
  $.each($("#divImage-Slide>div"),function(i) {
        if(currentDivToken  == i)
           $(this).show();
  });
      currentDivToken = (currentDivToken  == maxDivCaptionToken ) ? 0 :currentDivToken  + 1;
}
</script>


Simple add the div containing  Caption like as follow

<div id="divImage-Slide" style=" width: 100px;height: 100px;position: relative;">
   <div id="divImage1" style=" width: 100%;height: 100%;position: absolute;top: 0;left: 0;">
       <div id="divCaption1">aaaaaaaaaaaaaaaa</div>
   </div>
   <div id="divImage2" style=" width: 100%;height: 100%;position: absolute;top: 0;left: 0;">
        <div id="divCaption1">Chrysanthemum</div>
   </div>
 <div id="divImage2" style=" width: 100%;height: 100%;position: absolute;top: 0;left: 0;">
        <div id="divCaption1">Hello</div>
   </div>
</div>

Hope this will fix up your issues.
0
 

Author Closing Comment

by:Refael
Comment Utility
Thank you!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now