jquery keypress() event get text

前端 未结 4 1109
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 03:42

I want a function to be run when a keypress occurs on a text box, so I have this code:

$(\"input[x]\").keypress(function() {
        DoX();
    })
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 04:02

    You can try to use the keyup event:

    $(selector).keyup(function() {
      var textValue = $(this).val();
      DoX();
    });
    

提交回复
热议问题