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

317
Visualizações
on body click run one function after another click run another function

Is it possible to Call one function after click on body then call different function after the second click?

i tried and then stopped, any ideas?

$("html, body").one("click",function() {
  // to something
}
about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You could try something like this:

var clicks = 0;
$("html, body").on("click",function() {
    if(clicks === 0){
        funcA();
    } 
    if(clicks > 1){
        funcB();
    }
    clicks++;
}

Where funcA and func

about 4 years ago · Santiago Trujillo Relatório

0

Edit: I changed my answer due to your latest addition to your question. See this snippet:

var myFunctions = [];

myFunctions.push(function() {
  $("body").css("background-color", "red");
});

myFunctions.push(function() {
  $("body").css("background-color", "green");
});

$("html, body").click(function(){
  if(myFunctions.length > 0) myFunctions.shift()();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

about 4 years ago · Santiago Trujillo Relatório

0

html part :

<input type="button" value="Click Me" />

script part:

$("input").one("click",function() {
    alert("First Function");  
  $("input").one("click",function() {
    alert("Second Function");
  });
});

Demo

about 4 years ago · Santiago Trujillo 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