Skip to content

Commit 432263f

Browse files
authored
updated changeTheme for codesandbox
1 parent 3696540 commit 432263f

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎index.html‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@
2626
<script>
2727

2828
function getTheme () {
29-
function changeTheme (Theme) {
30-
document.getElementById('style').setAttribute('href', Theme);
29+
function changeTheme(themeUrl) {
30+
var elm = document.getElementById("style");
31+
elm && elm.remove();
32+
33+
var newCss = document.createElement("link");
34+
newCss.id = "style";
35+
newCss.rel = "stylesheet";
36+
newCss.type = "text/css";
37+
newCss.href = themeUrl;
38+
document.head.appendChild(newCss);
3139
}
3240
var index = document.getElementById("select").selectedIndex;
3341
switch (index) {

0 commit comments

Comments
 (0)