Bonjour,

Je cherche à écrire des fonctions chainable.

Je voudrais qu'une fonction personnelle s’exécute après une autre.

Pour le moment les 2 fonctions s’exécutent en même temps, et non l'une après l'autre.

Merci

ZapMtl
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script language="JavaScript" type="text/JavaScript">
(function($)
{
    $.fn.test4=function()
    {
      $('#animateTest1').animate({ left: '+=200' }, 2000);
      return $(this);
    };
	$.fn.test5=function()
    {
      $('#animateTest2').animate({ left: '+=200' }, 2000);
      return $(this);
    };
})(jQuery);
 
$(document).ready(function(){
  $().test4().test5();
});  
</script>
 
</head>
 
<body>
  <div id="animateTest1" style="top:10px;left:10px;width:50px;height:50px;background-color:Aqua;position:absolute;"></div>
  <div id="animateTest2" style="width:50px;height:50px;background-color:red;position:absolute;top:100px;"></div>
</body>
</html>