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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| <!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta http-equiv="cache-control" content="public, max-age=60">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Daniel Hagnoul">
<title>Test</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/le-frog/jquery-ui.min.css">
<style>
#vignette, #film { margin: 12px; }
#vignette > img { width: 30px; height: 30px; }
</style>
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/i18n/jquery-ui-i18n.min.js"></script>
<script>
'use strict';
$( function(){
/*
* Les vignettes et les images doivent avoir un point commun.
* Ici c'est le même URL.
* En général, on place les vignettes et les photos dans deux
* dossiers différents mais on conserve le même nom.
*/
var jObjImgFilm = $( '#imgFilm' );
$( 'img', '#vignette' ).on( 'click', function( ev ){
jObjImgFilm.attr( "src", $( this ).attr( "src" ) );
});
});
</script>
</head>
<body>
<div id="vignette">
<img src="https://t2.ftcdn.net/jpg/01/05/31/73/240_F_105317397_MKNdNA0e8bucBR6p4f5Fmu7qOvLFL2wY.jpg">
<img src="https://t1.ftcdn.net/jpg/00/27/94/22/240_F_27942212_2KE6w0CKiT9WEg8N6F7RAY8WoB4bwO5o.jpg">
<img src="https://t2.ftcdn.net/jpg/01/05/31/87/240_F_105318769_l4oaw6YMyuaGaNotVbHBrWptEEikZFzA.jpg">
</div>
<div id="film">
<img id="imgFilm" src="https://t2.ftcdn.net/jpg/01/05/31/73/240_F_105317397_MKNdNA0e8bucBR6p4f5Fmu7qOvLFL2wY.jpg">
</div>
</body>
</html> |
Partager