[英]How to load content into html elements according to style-sheet?
I'm having two style-sheets which can be loaded each by the user choice. 我有两个样式表,每个样式表都可以由用户选择加载。 My style-sheets are: one.css, two.css.
我的样式表是:one.css,two.css。 What I want is: If the user change the theme I want the content to be changed too.
我想要的是:如果用户更改主题,我也希望更改内容。 What I did is:
我所做的是:
function strcmp ( str1, str2 ) {
return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) ;
}
(function(){
var href = $('link').attr('href');
console.log(href); // check what style-sheet
if(strcmp(href,'one')==0)
$("#p1").html('this is the content for one.css');
$("#p1").append("still for one.css");
else if(strcmp(href,'two')==0)
$("#p1").html('this is the content for two.css');
$("#p1").append("still for two.css");
})();
My method is not working, any ideas? 我的方法不起作用,有什么想法吗?
the href must be "one.css" and not just "one" href必须是“ one.css”,而不仅仅是“ one”
try this: 尝试这个:
if(strcmp(href,'one.css')==0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.