Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 更改<;李>;在<;ul>;_Jquery_Html_Css_Asp.net_Asp.net Mvc - Fatal编程技术网

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;
      ......
}