Javascript change event on input element fires on only losing focus

前端 未结 7 2295
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 15:45

I have an input element and I want to keep checking the length of the contents and whenever the length becomes equal to a particular size, I want to enable the submit button

7条回答
  •  旧巷少年郎
    2020-11-27 16:18

    Do it the jQuery way:

    
    
    
    $('#name').keyup(function() {
      alert('Content length has changed to: '+$(this).val().length);
    });
    

提交回复
热议问题