将颜色应用于操作链接



我正在尝试更改ActionLink的字体,但是当我在末尾, null时,我无法更改它。

我尝试过的:

@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new { deviceID = item.DeviceID, type = "Verification", id = "Color" }, null)
window.onload = function () {
var x = "fontColor";
alert("color " + x);
if (x == "fontColor") {
$("#Color").css('color', "red");
}
else {
$("#Color").css('color', "green");
}
}

@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new { deviceID = item.DeviceID, type = "Verification", style = "color:red" }, null)

@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new { deviceID = item.DeviceID, type = "Verification", @class = "fontColor" }, null)

不能混合使用routeValueshtmlAttributes参数。这两者必须是不同的对象。

视图

@Html.ActionLink(" Verification |", "VerIndex", "MFC_Form", new {deviceID = item.DeviceID, type = "Verification"}, new { @class = "text-red" })

.CSS

.text-red {
color: red;
}

生成的链接如下所示:

<a class="text-red" href="/MFC_Form/VerIndex?deviceID=1&type=Verification"> Verification |</a>

最新更新