Jquery 更改<;李>;在<;ul>;
我在Jquery 更改<;李>;在<;ul>;,jquery,html,css,asp.net,asp.net-mvc,Jquery,Html,Css,Asp.net,Asp.net Mvc,我在 给你 <ul class="nav navbar-nav navbar-right" style="color:black;"> <li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li> <li>@Html.ActionLink("Lo
给你
<ul class="nav navbar-nav navbar-right" style="color:black;">
<li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
</ul>
但颜色没有改变
如何更改它?这应该可以:
<ul class="nav navbar-nav navbar-right">
<li style="color:black;">@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li style="color:black;">@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
</ul>
在ActionLink中的“HtmlatAttributes”中添加类
@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink", @class = "aclass" })
在css中:
/* Class of 'a' element
.aclass {
color: black;
......
}
这应该行得通
编辑:
您必须使用“@”,因为类在C#中是一个关键字。
链接到MSDN文档:
是ASP吗?请显示呈现的HTML。看起来这些将生成
a
标记,因此您需要将样式应用于a
或使用类似的内容。nav a{color:black;}
是,将更新postnow@MichaelCokerYou想在>@Html.ActionLinkTry中使用'@class=“aclass”'而不是'class=“aclass”'来尝试htmlAttributes:new{@style='color:black'}。在类属性之前添加“@”。(我已经编辑了我的答案)@s.e。
@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink", @class = "aclass" })
/* Class of 'a' element
.aclass {
color: black;
......
}