How to monitor the change of an input type text field?

3

I need to monitor the change of the contents of a text field, the function I use is this:

$(document).ready(function() {

  $("#nome").on("keyup change click focus", function() {
    $(".classenome").val($(this).val());
  });

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script><inputtype="text" id="nome" value="">
<input type="text" id="duble" class="classenome" value="">

I tried all the above events, when the user types directly into the "name" field works fine because of the keyup, but if it fills in that list of history that the browser suggests the function only works when it exits the field by cause of the "change" event.

Is there any other event that monitors if the value / text is history?

I'm thinking that I'll have to develop a timer for this, but I did not want to.

    
asked by anonymous 10.06.2016 / 23:40

1 answer

6

Uses input event, tested on Chrome and Firefox now, and works when the browser does auto complete.

var input = document.querySelector('input');
input.addEventListener('input', function() {
  console.log('input', this.value);
});

jsFiddle: link

    
10.06.2016 / 23:58