| 12
 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
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 
 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr">
<head>
   <title>modification d'une image au clique</title>
	<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
   <style type="text/css">
   
   </style>
</head>
<body>
   <img src="img/1.gif" alt="test" />
   <script type="text/javascript">
   var Utils = {
      Evenement: {
         ajouter: function(elm, evt, fn) {
            if (document.addEventListener) {
                if (elm.length === undefined) {
                    elm.addEventListener(evt, function(e) {
                        fn(e);
                    }, false);
                } else {
                    for (var i = 0, imax = elm.length; i < imax; i++) {
                        elm[i].addEventListener(evt, function(e) {
                            fn(e);
                        }, false);
                    }
                }
            } else if (document.attachEvent) {
               if (elm.length === undefined) {
                  elm.attachEvent("on" + evt, fn);
               } else {
                 for (var i = 0, imax = elm.length; i < imax; i++) {
                     elm[i].attachEvent("on" + evt, fn);
                 }
               }
            }
         }
      },
      changeImage: function(elm, i1, i2) {
         (elm.src.indexOf(i1)>-1) ? elm.src=i2 : elm.src=i1;
      }
   }
   Utils.Evenement.ajouter(document, "click", function(e){
      var elm = e.target || e.srcElement;
      if (elm.src) {Utils.changeImage(elm, "img/1.gif", "img/2.gif");}
   });
   </script>
</body>
</html> | 
Partager