From b883d3734ac4dd09d9dc2257afca048faf1ec5c7 Mon Sep 17 00:00:00 2001 From: hhhJB Date: Wed, 15 Nov 2023 16:14:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=8F=98=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- test1.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index d7db5bc..207aa89 100644 --- a/index.html +++ b/index.html @@ -82,7 +82,7 @@

添加几个按钮/开关 并在后面添加随机数字 ----李岳烁 23.11
- +
diff --git a/test1.js b/test1.js index 64e833a..1e339ec 100644 --- a/test1.js +++ b/test1.js @@ -2,4 +2,13 @@ function addone(id) { var elem = document.getElementById(id); var presnt = parseInt(elem.value) || 0; elem.value = presnt + 1; -} \ No newline at end of file +} +function changecolor() { + let button = document.getElementById("num2"); // access the button by id + let color = button.style.color; + if (color == "red") { // if button color is red change it green otherwise change it to red. + button.style.color = 'green'; + } else { + button.style.color = 'red'; + } + } \ No newline at end of file