Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6372459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:14:31+00:00 2026-05-25T01:14:31+00:00

Possible Duplicate: "Flashing" random text with javascript I can’t figure out how to make

  • 0

Possible Duplicate:
"Flashing" random text with javascript

I can’t figure out how to make this maybe stupid thing.
I have several text phrases that I have to switch between and loop with fading transition.

How can I build this stuff in jQUery?
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:14:31+00:00Added an answer on May 25, 2026 at 1:14 am

    HTML —

    <div id="container">
        <p>Text 1</p>
        <p>Text 2</p>
        <p>Text 3</p>
        <p>Text 4</p>
    </div>
    

    CSS —

    #container {
        position: relative;
    }
    #container p {
        position: absolute;
        top: 0;
        left: 0;
        display: none;
    }
    

    JavaScript —

    function rotate_p() {
        if (p_current == p_count) {
            p_current = 1;
        } else {
            p_current++;
        }
        var $container = $('#container');
        $container.find('p').fadeOut();
        $container.find('p:nth-child(' + p_current + ')').fadeIn();
    }
    
    var p_count;
    var p_current = 0;
    var p_interval;
    $(document).ready(function () {
        p_count = $('#container').find('p').length;
        p_interval = setInterval(function () {rotate_p();}, 2500);
    });
    

    This uses an interval to loop through the <p> tags within a container <div>. The <p> tags are set to the same location so the fade in/out will appear on top of each other. On document load the number of <p> tags are found and stored in a global variable. The function that runs in the interval hides all the <p> tags within the containing <div> and then shows the next one in line.

    Here is a jsfiddle of the above code: http://jsfiddle.net/Z8s7d/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: I can't figure out what's wrong with my NullPointerException or why it
Possible Duplicate: Multiline strings in Javascript In Ruby you can do something like this:
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: Oracle "(+)" Operator Can some one tell me what does (+) sign
Possible Duplicate: style type="text/css" … what else is there? I see that when defining
Possible Duplicate: An algorithm to "spacify" CamelCased strings I have a string like this:
Possible Duplicate: Can I "multiply" a string (in C#)? In Python I can do
Possible Duplicate: java: "final" System.out, System.in and System.err? It's just occurred to me although
Possible Duplicate: Why avoid increment ("++") and decrement ("--") operators in JavaScript? I've recently
Possible Duplicate: When should I use double or single quotes in JavaScript? Do ""

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.