Ejemplo callback Jquery

Con jquery podemos darnos cuenta cuando termina el proceso
de alguna acción que este en ejecución utilizando el callback de jquery.

con el callback podemos definir que accion efectuar despues
de que termine x proceso.

a continuación mostrare un ejemplo utilizando el callback.:

CallBack Jquery


En este ejemplo efectúo la acción de avisar por que animación
se esta ejecutando la función del boton1.


aqui el codigo:

<!doctype html>
<html>
<head>
 <meta charset="utf-8">
 <title>appletenhtml callback jquery</title>
    <script src="jquery-1.11.2.js"></script>
 
</head>
<body>

 <article>
  <section>
   <div id="dv" style="width:107px;height:24px;background-color:yellow; position:absolute"></div>
   <br><br><br><br /><button id="boton1">Mover</button>  
  </section>
  <div id="msj1"></div>
   </article> 
 <script>
 
 $(document).ready(function(){
  $("#boton1").click(function(){
      $("#dv").animate({right:'600px', opacity:'0.2'},"slow",function(){ $("#msj1").html("Animacion 1");});
      $("#dv").animate({left:'550px', opacity:'0.15'},"fast",function(){ $("#msj1").html("Animacion 2");});
      $("#dv").animate({height:'400px',width:'420px', opacity:'0.5'},"slow",function(){ $("#msj1").html("Animacion 3");});
      $("#dv").animate({left:'350px'},"fast", function(){ $("#msj1").html("Animacion 4");});
     
  });

});
  </script> 


</body>
</html>



Ten en cuenta que para que funcione el codigo debes de tener el jquery
aqui el link: Jquery1.11.2.js


Descargar ejemplo: example slide jquery


Comentarios

Populares

Buscar en este blog