【问题标题】:How to get attribute from actionlink如何从 actionlink 中获取属性
【发布时间】:2015-06-03 15:10:21
【问题描述】:

如何从 ActionLink 获取属性?我有这个:

<table>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.ActionLink(item.Name, "Chat", "Home", new { id = item.ID }, new { @class = "Group" })<br />
            </td>
        </tr>
    }
</table>

在重定向页面上我需要得到item.name

这是我的 JS:

$('#rooms ul li').not('.nav-header').click(function(e) {
    e.preventDefault();

    $('#rooms ul li').not('.nav-header').removeClass('active');

    $(this).addClass('active');
    var roomKey = $(this).data('value');
    hub.server.joinGroup(roomKey);
});

【问题讨论】:

  • 检查元素时是否在 DOM 中显示 href 属性?

标签: jquery asp.net-mvc razor knockout.js


【解决方案1】:

你可以简单地 attr() 事件

$(selector).attr('/form or id or class any on of attribute/');

【讨论】:

  • 感谢您的解决方案,这对获得名字有好处吗? 'var roomKey = $(selector).attr('item.Name');'
猜你喜欢
  • 2011-05-05
  • 1970-01-01
  • 1970-01-01
  • 2015-01-27
  • 1970-01-01
  • 2018-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多