How do i bind onchange event of a TextBox using JQuery?

后端 未结 7 989
我在风中等你
我在风中等你 2020-12-09 15:44

How can I bind an OnChange event of a TextBox to function using jQuery?

Am trying this and its failing:

$(document).ready(function() {
    $(\"input#         


        
7条回答
  •  暖寄归人
    2020-12-09 16:07

    You must change the event name from "change" to "onchange":

    $(document).ready(function(){
            $("input#tags").bind("onchange", autoFill);
              });
    

    or use the shortcut binder method change:

    $(document).ready(function(){
            $("input#tags").change(autoFill);
              });
    

    Note that the onchange event usually fires when the user leave the input, so for auto-complete you better use the keydown event.

提交回复
热议问题