Q:

Ignore focus on jquery.change

For example I have the following code:
    $(".someSelector").change(function()
    {
        // Do something

        // Call function

        // console.log('test')

    });

The problem is, it is being called twice: whenever I lose focus of the input field and whenever the value changes.
I want it to be called only whenever the value changes.
Is there a way to ignore focus loss on the .change other than comparing old input value with the new input value?

A:

You should use the input event instead of change.
input is fired on each value change (including paste); changefires on blur when the value has changed.
$(".someSelector").on('input', function() {
    // Do something
});

The input event is supported by IE9+.

