使用本地存储切换背景

时间:2017-01-24 08:32:24

标签: css jquery-ui themes local-storage toggle

一旦页面刷新,我的主题就会改变。一旦我们更改主题(刷新页面后),请帮助我获得相同样式的页面。

演示。 https://jsfiddle.net/aopf97z3/1/

刷新页面后,当前类不会出现。 代码:

<body>
    <div class="theme_change">Change Your Theme</div>    
    <div class="content">The below content is the Test content</div>    
</body>

CSS:

body {
  background:#fff;
  color:#000;
}
.content {
  background:#f00;
  color:#fff;
}
.black_theme {
  background:#2180c7;
  color:#000;
}   

脚本:

$('.theme_change').on('click', function() { 
    $('body').toggleClass('black_theme');       
    $('this').toggle(); 
});

先谢谢。

0 个答案:

没有答案