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
| <!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>
<style>
.lettre {
display: none;
}
</style>
<script>
'use strict';
document.addEventListener( 'DOMContentLoaded', ev => {
}, false );
window.addEventListener( 'load', ev => {
const
chiffres = document.querySelectorAll( ".chiffre" ),
lettres = document.querySelectorAll( ".lettre" );
for ( let [ i, chiffre ] of Array.from( chiffres ).entries() ){
chiffre.addEventListener( "click", () => {
lettres[ i ].style.display = "block";
}, false );
}
}, false );
</script>
</head>
<body>
<main>
<p class="chiffre">1</p>
<p class="lettre">un</p>
<p class="chiffre">2</p>
<p class="lettre">deux</p>
</main>
</body>
</html> |
Partager