From 9105ee0108bbea7d95e0fb7d3b8da919a1ddd5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Wed, 27 Sep 2023 21:36:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E4=B8=AD=E5=AF=B9=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/index.html b/public/index.html index a7cc14f..a6a6da6 100644 --- a/public/index.html +++ b/public/index.html @@ -43,6 +43,20 @@ const li = document.createElement('li') li.innerText = `id:${data.id} channel:${data.channel}` li.id = data.id + li.onclick = async () => { + console.log('点击设备', data.id) + // 清理所有选中状态 + clients.forEach(client => { + const li = document.getElementById(client.id) + if (data.id === client.id) { + li.style.backgroundColor = 'red' + console.log('设置选中状态', data.id) + return + } + li.style.backgroundColor = 'transparent' + console.log('清理选中状态', client.id) + }) + } ul.appendChild(li) return }