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

  • SEARCH
  • Home
  • 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 8007605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:53:08+00:00 2026-06-04T17:53:08+00:00

How would you improve this so I wouldn’t have to keep repeating?. I will

  • 0

How would you improve this so I wouldn’t have to keep repeating?. I will need to create 50 options.

var timer = 300;

function showLabels() {
    $('#machine ul#labels li span').animate({'top': '0px'},'slow');
}
function option1() {
    setTimeout(function() { $('#prize-details #prize-text h1').html("Header"); }, timer);
    setTimeout(function() { $('#prize-details #prize-text p').html("Text here"); }, timer);
    $('#machine ul#labels li#what').html('<span>1</span>');
    $('#machine ul#labels li#where').html('<span>2</span>');
    $('#machine ul#labels li#with').html('<span>3</span>');
    $('#machine ul#labels li#in').html('<span>4</span>');
    showLabels();
}
function option2() {
        setTimeout(function() { $('#prize-details #prize-text h1').html("Different header here."); }, timer);
        setTimeout(function() { $('#prize-details #prize-text p').html("Different text here"); }, timer);
        $('#machine ul#labels li#what').html('<span>5</span>');
        $('#machine ul#labels li#where').html('<span>6</span>');
        $('#machine ul#labels li#with').html('<span>7</span>');
        $('#machine ul#labels li#in').html('<span>8</span>');
        showLabels();
    }
  • 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-06-04T17:53:10+00:00Added an answer on June 4, 2026 at 5:53 pm

    As both of your functions are similar so you can try with one function like

    var timer = 300;
    
    function showLabels() {
        $('#machine ul#labels li span').animate({'top': '0px'},'slow');
    }
    
    function option(header, para, span1, span2, span3, span4) {
        setTimeout(function() { 
             $('#prize-details #prize-text h1').html(header); 
             $('#prize-details #prize-text p').html(para); 
        }, timer);
    
        $('#what').html('<span>'+ span1 +'</span>');
        $('#where').html('<span>'+ span2 +'</span>');
        $('#with').html('<span>'+ span3 +'</span>');
        $('#in').html('<span>'+ span4 +'</span>');
    
        showLabels();
    }
    

    According to edit

    If each iteration have different text then call the above function with different parameters like:

    option('Header', 'Text here', 1, 2, 3, 4);
    option('Different Header', 'Different Text here', 5, 6, 7, 8);
    

    and so on.

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

Sidebar

Related Questions

I have read that you can do it, but would this really improve performance
Hi, I'm trying to find way how to improve this code. I would like
I would like to improve the speed of my script that uploads a small
I would like to improve the lambda-code generated for the assert OCaml 3.12.1 construct.
I am using Ruby on Rails 3.2.2 and I would like to improve code
Does running multiple Solr shards on a single machine improve performance? I would expect
Would my 'lite' version be removed if I have a 'pro' version on my
Would you prefer this: def add(a, b) puts ADDING #{a} + #{b} return a
So does implementing Dispose() on the managed objects where would improve Garbage Collector's performance
I am trying to create some HTML/CSS for footer navigation. What I would like

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.