如何访问@ url.content("〜/ content /" +" theme1.css")javascript中的参数 [英] How to access parameter within @url.content("~/content/" + "theme1.css") javascript
本文介绍了如何访问@ url.content("〜/ content /" +" theme1.css")javascript中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
How to access Parameter within @Url.Content("~/Content/" + "Theme1.css") javascript
我尝试过:
功能变更主题(姓名){
if(Name ==Theme1){
var thestyle = document.getElementById(style);
thestyle.href =@ Url.Content(〜/ Content /+Theme1.css);
}
}
代替主题1(@ url.Content(〜/ Content /+Theme1.css))我想使用Name变量
What I have tried:
function changetheme(Name) {
if (Name == "Theme1") {
var thestyle = document.getElementById("style");
thestyle.href = "@Url.Content("~/Content/" + "Theme1.css")";
}
}
instead on Theme1 in(@Url.Content("~/Content/" + "Theme1.css")) i want to use Name variable
推荐答案
试试这个
try this
<link id="themelink" href="~/Content/YourCurrentTheme.css" rel="stylesheet" />
<script>
function changetheme(Name) {
var thestyle = document.getElementById("themelink");
var styleName = Name + '.css';
var href = "@Url.Content("~/Content/")" + styleName;
thestyle.href = href;
}
</script>
这篇关于如何访问@ url.content("〜/ content /" +" theme1.css")javascript中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文