更新 'main.js'

This commit is contained in:
2023-03-01 20:44:42 +00:00
parent b4a04a8505
commit e53a1b06b6
+10 -9
View File
@@ -24,10 +24,10 @@
cursor: pointer; cursor: pointer;
} }
#auto_update_btn.close { #auto_update_btn.close {
background: green; background: red;
} }
#auto_update_btn.open { #auto_update_btn.open {
background: red; background: green;
} }
` `
/*添加样式*/ /*添加样式*/
@@ -44,9 +44,10 @@
/*生成自动升级建筑的按钮*/ /*生成自动升级建筑的按钮*/
function createBtn() { function createBtn() {
var btn = document.createElement("div") var btn = document.createElement("div")
btn.title = '开' btn.title = '未开启'
btn.className = 'close'
var span = document.createElement("span"); var span = document.createElement("span");
span.innerText = '开' span.innerText = '未开启'
btn.appendChild(span); btn.appendChild(span);
btn.id = 'auto_update_btn' btn.id = 'auto_update_btn'
document.body.appendChild(btn) document.body.appendChild(btn)
@@ -63,12 +64,12 @@
function toggleBtnText(){ function toggleBtnText(){
const node = document.querySelector('#auto_update_btn') const node = document.querySelector('#auto_update_btn')
const text = node.innerText const text = node.innerText
if (text === '开') { if (text === '未开启') {
node.innerText = '关' node.innerText = '运行中'
node.className = 'close'
} else {
node.innerText = '开'
node.className = 'open' node.className = 'open'
} else {
node.innerText = '未开启'
node.className = 'close'
} }
} }