【发布时间】:2016-12-23 22:47:11
【问题描述】:
我正在尝试通过单击一个按钮来更改 CSS 样式表。
<head>
<link id='link01' rel="stylesheet" href="blue.css">
</head>
JS
$('.pointcolors').click(function(){
var theme = $(this).attr('data-theme') + '.css';
console.log(theme); // green.css - it's ok
$('#link01').attr('src', theme);
});
但是没有样式变化。什么都没有发生。
有什么帮助吗?
【问题讨论】:
-
您可能正在更改 URL,但这并不一定意味着它会加载新的。