_viewStart.cshtml에서 jquery로 CSS 속성을 어떻게 설정합니까? 나는 CSS 속성을 _Viewstart.cshtml에 설정해야하기 때문에 CSS 파일을 viewstart에 가져 오는 방법을 알지 못합니다. 나는 속성을 변경하는 방법을 알고 있지만 CSS에서이 요소를 가져 오는 방법을 모른다.CSS 속성을 jquery로 설정
@using Repository
@using Services
@{
var servicetemp = ServiceFactory.Instance.CreateTemplateService();
Layout = "~/Views/Shared/_Layout.cshtml";
if (Request.IsAuthenticated)
{
var TemplateIDSession = Session["TemplateID"];
if (TemplateIDSession != null)
{
int tempID = (int)TemplateIDSession;
var template = servicetemp.GetEntry(tempID);
<script type="text/javascript">
$("Body").css({ background-color: "#" + "@template.TempBG" }),
$("Header").css({background-color: "#" + "@template.TempBG" });
</script>
}
}
}
--UPDATE-- 이 새로운 자바 스크립트 코드 :
<script type="text/javascript">
$("body").css('background-color:', '#' + '@template.TempBG'),
$("#Layout").css('background-color:', '#' + '@template.TempBG');
</script>
하지만 여전히 나던 작품은 CSS 요소의 값을 대체하기 위해이 내가 지금 할 얼마나 많은입니다 , CSS 파일은 다른 폴더에 있습니다.
사용 따옴표처럼 언급 할 그 시간에 더 CSS 속성을 원하는 경우에
같은 언급 할 : ... '. 또는 당신은'SyntaxError : Unexpected token -'을 얻을 것이다. – nnnnnn
@nnnnnn이 코드를 사용하여 속성을 설정할 수 있습니까? – user2043267
''# ''과''@ template.BGcolor' '사이에'+'를 붙이면 (예 :'body') .css ('배경색', '#' '@ template.BGcolor' 그렇다면 JS 측이가는 한 예. (나는 ASP 측이 어떻게 작동하는지 기억이 안 나는데, 너무 길다.) – nnnnnn