[Racine des codes] [Page précédente]

swap img onmouseover

/Html JavaSript/Image/swap img onmouseover.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<title>swap images</title>

<script type="text/javascript">
var img1 = new Image(); // declare une image img1
img1.src = "img1.jpg"; // fixe sa source
var img2 = new Image();
img2.src = "img2.jpg";
</script>
</head>
<body>
  Image qui change quand la souris passe dessus :<br/>
  <img src="img1.jpg" onMouseOver="this.src=img2.src" onMouseOut="this.src=img1.src"/>
</body>
</html>
[edit]