-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<button>Lancer le décompte</button> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
let button = document.querySelector("button"); | ||
let secondes = 10; | ||
let interval; | ||
|
||
button.addEventListener('click', start); | ||
|
||
function start() { | ||
interval = setInterval(decompte, 1000); | ||
} | ||
|
||
function decompte() { | ||
secondes--; | ||
if (secondes > 0) { | ||
document.querySelector('body').innerHTML += "<br/>" + secondes; | ||
} else { | ||
stop(); | ||
} | ||
} | ||
|
||
function stop() { | ||
clearInterval(interval); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<button>Afficher</button> | ||
<p>Le texte caché.</p> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let button = document.querySelector("button"); | ||
let p = document.querySelector("p"); | ||
let hidden = true; | ||
|
||
p.style.display = "none"; | ||
|
||
button.addEventListener('click', () => { | ||
if (hidden) { | ||
button.textContent = "Cacher"; | ||
p.style.display = ""; | ||
} else { | ||
button.textContent = "Afficher"; | ||
p.style.display = "none"; | ||
} | ||
hidden = !hidden; | ||
}); |