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.
8
-
why do you want to do this? are you unable to edit the html to remove the files you don't want?Cruiser– Cruiser2016-05-24 13:27:00 +00:00Commented May 24, 2016 at 13:27
-
Actually, I am trying to change css file dynamically.madhan kumar– madhan kumar2016-05-24 13:28:41 +00:00Commented May 24, 2016 at 13:28
-
2@madhankumar you cannot do that. But you can always change the CSS individual properties dynamicallyAhs N– Ahs N2016-05-24 13:31:17 +00:00Commented May 24, 2016 at 13:31
-
1You can't disable css files with javascript. The proper way of doing it would be to add/remove css classes with javascript and/or use css media queries to display certain rules when you want to. Google CSS Media Queries and Changing CSS Class with javascript/jquery.Dan Weber– Dan Weber2016-05-24 13:36:43 +00:00Commented May 24, 2016 at 13:36
-
2see this answer: stackoverflow.com/questions/25827756/…Cruiser– Cruiser2016-05-24 13:37:41 +00:00Commented May 24, 2016 at 13:37
|
Show 3 more comments
1 Answer
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