
功能介绍:主题切换,选择不同主题动态切换相应的.css文件,从localStorage中获取对应的文件id,下面web建站小编给大家简单介绍一下插入方法!
具体代码如下:
function loadStyles(url) {
  var link = document.createElement("link");
  link.rel = "stylesheet";
  link.type = "text/css";
  link.href = url;
  var head = document.getElementsByTagName("head")[0];
  head.appendChild(link);
}
//主题
let theme = localStorage.getItem('theme')
loadStyles("/static/css/version-" + theme + ".css");
JavaScript获取指定网站状态码查询代码(2种实现方法)
上面是“js根据不同条件动态的引入不同的css样式(适用于不同主题)”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3806.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

 Java代码如何结合高德地图API实现实时公交到站信息查询
 ComfyUI绘画生成提示“conv_in.weight”错误解决方法
 游戏时光VGTime:专注于游戏资讯、评测、专题和电商的综合游戏平台
 AppScan扫描js报缺少Content-Security-Policy等安全漏洞问题解决方案