From e53a1b06b634eae9a8ca8a19ef07d0fe7c805c63 Mon Sep 17 00:00:00 2001 From: koderx Date: Wed, 1 Mar 2023 20:44:42 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'main.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index 0f995fd..2d9dfb0 100644 --- a/main.js +++ b/main.js @@ -24,10 +24,10 @@ cursor: pointer; } #auto_update_btn.close { - background: green; + background: red; } #auto_update_btn.open { - background: red; + background: green; } ` /*添加样式*/ @@ -44,9 +44,10 @@ /*生成自动升级建筑的按钮*/ function createBtn() { var btn = document.createElement("div") - btn.title = '开' + btn.title = '未开启' + btn.className = 'close' var span = document.createElement("span"); - span.innerText = '开' + span.innerText = '未开启' btn.appendChild(span); btn.id = 'auto_update_btn' document.body.appendChild(btn) @@ -63,12 +64,12 @@ function toggleBtnText(){ const node = document.querySelector('#auto_update_btn') const text = node.innerText - if (text === '开') { - node.innerText = '关' - node.className = 'close' - } else { - node.innerText = '开' + if (text === '未开启') { + node.innerText = '运行中' node.className = 'open' + } else { + node.innerText = '未开启' + node.className = 'close' } }