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 6532121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:57:41+00:00 2026-05-25T09:57:41+00:00

Here’s what I have so far: var timer = setInterval(function () { $(.auctiondiv .auctiondivleftcontainer

  • 0

Here’s what I have so far:

var timer = setInterval(function () {
    $(".auctiondiv .auctiondivleftcontainer .countdown").text(sec--);
}, 1000);

This works fine, but the problem arises because I have to set the value of sec on startup and every countdown element on my page has the same value. So instead of saving the value and decreasing that, maybe it’s best to just get the value each tick and decrease it – without saving the value anywhere in Javascript.

How can I grab the text inside of the .countdown element (a <p> tag) and subract one from it and assign it back to the same <p> element? What has me confused is that there are many .countdown elements on my page, how would I go through each one?

I also need to make sure that a .countdown value once it reaches zero, I can do something. A conditional so to speak. I imagine I can use .parent() on it, but we’ll see.

Any guidance?

  • 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-25T09:57:42+00:00Added an answer on May 25, 2026 at 9:57 am

    You can use the jQuery each method to iterate over the matched set of elements:

    var timer = setInterval(function () {
        $(".countdown").each(function() {
            var newValue = parseInt($(this).text(), 10) - 1;
            $(this).text(newValue);
            if(newValue == 0) {
               //Do something
            }
        });
    }, 1000);
    

    I’ve changed the selector to just .countdown because you said you have many such elements on the page, and I’m assuming they’re not all going to be matched by your original selector, but you can obviously change that as necessary.

    Here’s a working example of the above code.

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

Sidebar

Related Questions

Here's my problem I have this javascript if (exchRate != ) { function roundthecon()
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
Here is what I want to do. Use this HTML line and have the
Here is what I am trying to achieve in PHP: I have this string:
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here we go again, the old argument still arises... Would we better have a
Here is what I have: Dim cmsManager As New Telerik.Cms.CmsManager() Dim currentNode As Telerik.Cms.Web.CmsSiteMapNode

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.