jQuery get input value after keypress

后端 未结 9 1601
野趣味
野趣味 2020-11-28 21:40

I have the following function:

$(document).ready(function() {
    $(\"#dSuggest\").keypress(function() {
        var dInput = $(\'input:text[name=dSuggest]\'         


        
9条回答
  •  情深已故
    2020-11-28 22:04

    I was looking for a ES6 example (so it could pass my linter) So for other people who are looking for the same:

    $('#dSuggest').keyup((e) => {
        console.log(e.currentTarget.value);
    });
    

    I would also use keyup because you get the current value that is filled in.

提交回复
热议问题