Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

show cpations in sequence

Posted on 2012-03-29
4
Medium Priority
?
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

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

Author Comment

by:Refael
ID: 37781033
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 2000 total points
ID: 37781206
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
ID: 37821877
Thank you!
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

715 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