【问题标题】:attr("disabled", false) causing error in Typescriptattr("disabled", false) 在 Typescript 中导致错误
【发布时间】:2023-04-07 22:32:01
【问题描述】:

我的 ts 文件中有以下代码:

 $('input[type=hidden]').attr("disabled", false);

代码有效,但我收到以下错误: “false”类型的参数不能分配给“string |”类型的参数号码 | ((this: HTMLElement, index: number, attr: string) => string | number | void)'。

【问题讨论】:

标签: javascript typescript input disabled-input


【解决方案1】:

您应该完全删除属性。

 $('input[type=hidden]').removeAttr("disabled");

【讨论】:

    【解决方案2】:

    尝试将false 作为字符串传递。

     $('input[type=hidden]').attr("disabled", "false");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-05
      • 2011-08-28
      • 2019-01-07
      • 2018-04-05
      • 1970-01-01
      • 2015-10-03
      • 2018-11-23
      相关资源
      最近更新 更多