如何使用jquery

时间:2017-03-02 08:12:43

标签: jquery asp.net-mvc

在以下隐藏字段中有一个css类" NSE_View_Delete"。附加

我想动态更改并追加其他css类..

@Html.Hidden("ViewGroupDetails", Url.Action("ViewGroupDetails", "NSEDownload", new { acid = InsiderTrading.Common.ConstEnum.UserActions.NSEDownload }), new { @class = "gridtypecontrol", ctrtype = "link", gridcolumntype = @ViewBag.GridType + "_usr_grd_11073", param = "{'text':'','href':'" + Url.Action("ViewGroupDetails", "NSEDownload", new { acid = InsiderTrading.Common.ConstEnum.UserActions.NSEDownload }) + "&GroupId=<GroupId>','class':'NSE_View_Delete','text':'View/Delete'}" })
if (obj.aData['nse_grd_50431'] != null) {
  var abc = obj.aData['nse_grd_50431'];
  if (abc == 0) {
    $('#ViewGroupDetails').addClass('loading123').removeClass('NSE_View_Delete');
  }

在浏览器中呈现的隐藏字段如下:

<a href="/NSEDownload/ViewGroupDetails?acid=223&amp;GroupId=773" class="NSE_View_Delete">View/Delete</a>

我该怎么做?

1 个答案:

答案 0 :(得分:0)

要使用class设置元素的jQuery属性,您可以尝试这样做:

$("#elementId").removeClass("removed-css-class"); //first remove the class
$("#elementId").addClass("added-css-class"); //then set classs

希望这会有所帮助......