How to get text of an input text box during onKeyPress?

前端 未结 12 1644
遥遥无期
遥遥无期 2020-11-28 05:12

I am trying to get the text in a text box as the user types in it (jsfiddle playground):

12条回答
  •  忘掉有多难
    2020-11-28 06:09

    There is a better way to do this. Use the concat Method. Example

    declare a global variable. this works good on angular 10, just pass it to Vanilla JavaScript. Example:

    HTML


    The text box contains:

    CODE

    emptyString = ''
    
    edValueKeyPress ($event){
       this.emptyString = this.emptyString.concat($event.key);
       console.log(this.emptyString);
    }
    

提交回复
热议问题