【问题标题】:Content not clearing after select and type on it in text box选择并在文本框中键入内容后未清除内容
【发布时间】:2018-10-26 15:12:56
【问题描述】:

如何自动覆盖所选内容?

我在 html 表格中有一个文本框。那里我使用以下 ng-pattern 来获得 2 位小数。

ng-pattern="/^(?:(?=[1-9])([0-9]+(\.[0-9]{1,7}){0,1})|(?=[0-0])(0+\.[0-9]{0,1}[1-9]([0-9]*)))$/"

当文本框中有一个带有两位小数的值并且我试图选择该值并在其上键入时,之前的内容不会被删除。

【问题讨论】:

  • 能否也添加你的html代码和.ts文件代码
  • 我已经格式化了你的代码并稍微改写了你的问题。

标签: html angular


【解决方案1】:

使用onfocus="this.value='';"始终清除该字段。

前-:

<input type="text" onfocus=" { this.value = ''; }" value="value" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多