使用JavaScript动态启用和禁用CSS文件?
问题描述:
我对javascript很陌生.我正在创建一个多语言网站.它包含rtl和ltr语言.对于语言,我有两个CSS.当用户更改其语言时,我想加载相应的CSS文件.有可能以这种方式吗?如果没有建议其他方法.
I am very new to javascript. I am creating a multilingual website. It contains rtl and ltr languages. I have two css for those to languages. When user change his language I want to load respective css file. Is it possible in this way ? If not suggest any alternative way.
答
是否可以使用javascript启用和禁用CSS样式表.例如: http://plnkr.co/0exLXB
Is posible enable and disable css stylesheet with javascript. A example: http://plnkr.co/0exLXB
function del_style() {
document.getElementById("styles").disabled=true;
}
function add_style() {
document.getElementById("styles").disabled=false;
}
我认为您可以为您的网站改编代码
I think you could adapt the code for your site