How to make changeable themes using CSS and JavaScript

后端 未结 6 1076
礼貌的吻别
礼貌的吻别 2020-11-28 22:42

I\'m pretty new to CSS and JavaScript and I was wondering if you could make a script that allows you to change what stylesheet the site uses.

Say: you had a green t

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 23:29

    You can set an Id to the link tag and switch the css at runtime.

    HTML

    
    

    JS

    document.getElementById('buttonID').onclick = function () { 
        document.getElementById('theme_css').href = '../red.css';
    };
    

提交回复
热议问题