How do I implement onchange of <input type=“text”> with jQuery?

后端 未结 14 1057
[愿得一人]
[愿得一人] 2020-11-27 10:15

?

相关标签:
14条回答
  • 2020-11-27 11:16
    $("input").change(function () {
        alert("Changed!");
    });
    
    0 讨论(0)
  • 2020-11-27 11:20

    I would suggest using the keyup event something like below:

    $('elementName').keyup(function() {
     alert("Key up detected");
    });
    

    There are a few ways of achieving the same result so I guess it's down to preference and depends on how you want it to work exactly.

    Update: This only works for manual input not copy and paste.

    For copy and paste I would recommend the following:

    $('elementName').on('input',function(e){
     // Code here
    });
    
    0 讨论(0)
提交回复
热议问题