From ed184eff56c0ce710eeda48ec3e71b23f80b7e1e Mon Sep 17 00:00:00 2001 From: Minhao Qiu <minhao.qiu@fau.de> Date: Mon, 15 Jul 2019 18:10:28 +0200 Subject: [PATCH] udpate --- app_7/counter.js | 14 ++++++++++++++ app_7/counter1.html | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 app_7/counter.js create mode 100644 app_7/counter1.html diff --git a/app_7/counter.js b/app_7/counter.js new file mode 100644 index 0000000..bde5f05 --- /dev/null +++ b/app_7/counter.js @@ -0,0 +1,14 @@ +document.addEventListener('DOMContentLoaded', function() { + document.querySelector('button').onclick = count; +}); + +let counter = 0; + +function count() { + counter++; + document.querySelector(`#counter`).innerHTML = counter; + + if (counter % 10 === 0) { + alert(`Counter is at ${counter}!`); + } +} diff --git a/app_7/counter1.html b/app_7/counter1.html new file mode 100644 index 0000000..95f9499 --- /dev/null +++ b/app_7/counter1.html @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<html> + <head> + <script src="counter.js"></script> + <title>My website</title> + </head> + + <body> + <h1 id="counter">0</h1> + <button>Click here!</button> + </body> +</html> -- GitLab