Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

324
Vistas
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
}
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

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

over 4 years ago · Santiago Trujillo Denunciar

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>

over 4 years ago · Santiago Trujillo Denunciar

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

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda