javascript - jQuery 表达式未被识别

标签 javascript jquery asp.net-mvc-4

我的 View 中有以下 html

<div id="divLoginName" style="display: none">
        <input type="hidden" id="hidLoginName" />
        @Html.TextBox("txtEditLoginName", null, new { maxlength = "1000", tabindex = "0", Multiline = false, @style = "width: 350px;" })
    </div>

以及以下 jquery 行

  var loginName = $.trim($tr.find(".tdLoginName").html());
  $("#divLoginName input:[type='text']").val(loginName);

我在这一行遇到以下错误 $("#divLoginName input:[type='text']").val(loginName);

Error: Syntax error, unrecognized expression: #divLoginName input:[type='text']

最佳答案

输入后删除冒号:

$("#divLoginName input[type='text']")
                     ^^^
                no colon there

关于javascript - jQuery 表达式未被识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29304058/

相关文章:

javascript - 添加几个类实例到 'container'类属性对象

javascript - 在加载的网页上点击 anchor 标记按钮,然后使用 vba 点击“确定”按钮

c# - 在 MVC 中日期时间?不工作

javascript - 最佳实践 javascript 和多语言

javascript - 将鼠标悬停在圆 Angular 按钮的一 Angular 上

javascript - 我应该有一个大的 redux-form 还是多个

javascript - MVC Web Api 使用 Ajax 获取数据

javascript - 使用 jQuery 根据其文本而不是值从菜单中选择选项

c# - 我将如何在 ASP.Net 服务器上运行连续任务?

javascript - 使用 session 来存储复选框的状态