How to detect a textbox's content has changed

后端 未结 15 1921
猫巷女王i
猫巷女王i 2020-11-22 16:10

I want to detect whenever a textbox\'s content has changed. I can use the keyup method, but that will also detect keystrokes which do not generate letters, like the arrow ke

15条回答
  •  太阳男子
    2020-11-22 16:28

    document.getElementById('txtrate' + rowCount).onchange = function () {            
           // your logic
    };
    

    This one works fine but triggers the event on click too which is not good. my system went into loop. while

    $('#txtrate'+rowCount).bind('input', function() {
            //your logic
    } );
    

    works perfectly in my scenario. it only works when value is changed. instead of $ sign one can use document.getElementById too

提交回复
热议问题