如何在网站的页面刷新中保存切换按钮的“开/关”模式?

I am trying to use the W3Schools Toggle Switch for my website Dark/Light Mode Toggle.

This is my Website Test Page in which I have added the Toggle Switch but the thing which happens is that the switch is not able to save it's "on/off" mode when the page is refreshed.

当我刷新页面时,它恢复为默认的“关闭”模式。

如何保存页面刷新上的位置?

谢谢

评论
  • 呐个牠
    呐个牠 回复

    您可以存储切换状态(打开或关闭本地存储)并从本地存储获取值。