所以我有一個(gè)時(shí)鐘腳本,當(dāng)您單擊開始時(shí),將顯示當(dāng)前時(shí)間。單擊“停止”時(shí)也會發(fā)生同樣的情況。我現(xiàn)在想要發(fā)生的是,當(dāng)我單擊第一個(gè)按鈕時(shí),第二個(gè)按鈕將被激活,因?yàn)槟荒茉趩螕舻谝粋€(gè)按鈕時(shí)單擊第二個(gè)按鈕。我的 HTML**<!DOCTYPE html><html dir="ltr"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <link rel="stylesheet" href="style/new-style.css"> <title>Digital Clock</title></head><body><center> <button class="panel2" onclick="CurrentTime()">Start rit</button> <p>Start van de Rit: <span id="Start Rit" /></p> <button class="panel1" onclick="ZaWarduu()">Stop rit</button> <p>Einde van de Rit: <span id="Einde Rit"/></p> <p>Clock : <span id="Clock" /></p> <script type="text/javascript"> </script> </center> </body> </html>我查看了有關(guān)堆棧溢出的幾個(gè)類似問題,并嘗試查看谷歌中的一些搜索結(jié)果,不幸的是我找不到任何內(nèi)容。
1 回答

慕的地8271018
TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個(gè)贊
例如,可以通過 localStorage 在這兩個(gè)按鈕之間共享狀態(tài),如果您想增加復(fù)雜性,也可以通過 Redux 之類的存儲來共享狀態(tài):)
- 1 回答
- 0 關(guān)注
- 170 瀏覽
添加回答
舉報(bào)
0/150
提交
取消