Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
countdown timer didn't show up

enter image description here before enter image description here after refreshing countdown didn't showed up and its goes disabled

when I refresh the page my countdown timer works perfectly, but when I refresh only particular div my countdown wont show up and button gets disabled.

note: I useed disabled tag to disabled my button

function refreshDiv() {
  $('#container3').load(window.location.href + " #container3 >");
}

JavaScript

var spn = document.getElementById("count");
var btn = document.getElementById("btnCounter");

var count = 2; // Set count
var timer = null; // For referencing the timer

(function countDown() {
  // Display counter and start counting down
  spn.textContent = count;

  // Run the function again every second if the count is not zero
  if (count !== 0) {
    timer = setTimeout(countDown, 1000);
    count--; // decrease the timer
  } else {
    // Enable the button
    btn.removeAttribute("disabled");
  }
}());

this is my html code its work properly when I refresh the whole page but when I refresh #container3 my button got disabled and countdown didn't showed

  <div class="container2" id="container3">
    <h4 id="title">here</h4>
    <div class="controls">
        <div class="main-controls">
            <div class="dropdown">
                <button
                    class="btn btn-primary dropdown-toggle" 
                    data-bs-toggle="dropdown"  id="btnCounter" disabled
                >
                    File <span id="count"></span>
                </button>
                <div class="dropdown-menu">
                    
                    <button id="txt-btn" class="dropdown-item" 
            onclick="refreshDiv();">
                        Save here
                    </button>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think this is the solution but I'm not sure I understand correctly what you're trying to do:

var spn = document.getElementById("count");
var btn = document.getElementById("btnCounter");

var count = 2; // Set count
var timer = null; // For referencing the timer

(function countDown() {
  // Display counter and start counting down
  spn.textContent = count;

  // Run the function again every second if the count is not zero
  if (count !== 0) {
    timer = setTimeout(countDown, 1000);
    count--; // decrease the timer
  } else {
    // Enable the button
    btn.removeAttribute("disabled");
  }
}());

function refreshDiv() {
  location.reload();
}
this is my html code its work properly when I refresh the whole page but when I refresh #container3 my button got disabled and countdown didn't showed

<div class="container2" id="container3">
  <h4 id="title">Title</h4>
  <div class="controls">
    <div class="main-controls">
      <div class="dropdown">
        <button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" id="btnCounter" disabled>
          File <span id="count"></span>
        </button>
        <div class="dropdown-menu">
          <button id="txt-btn" class="dropdown-item" onclick="refreshDiv();">Save</button>
        </div>
      </div>
    </div>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda