0

I was searching the web for how to fire of some jQuery code if the value of an input inside a form changes if it gets changed through a script that sets it's value with .val(). on('change') sadly only listens to the blur of an input. Is there a way to get around this?

I want to listen to the form which contains many inputs, if something changes inside.

  • perhaps your code is wrong. We'll never know, because you haven't posted any code – Jaromanda X Apr 02 '18 at 04:08
  • 1
    Possible duplicate of [javascript change event on input element fires on only losing focus](https://stackoverflow.com/questions/7105997/javascript-change-event-on-input-element-fires-on-only-losing-focus) – H77 Apr 02 '18 at 04:09
  • The question is kinda what I need, but that just counts for event listeners that are set to specific inputs. I am having a form with many inputs and >I want to listen to that form, if something changes inside. – ぽlっかいえゔぁん Apr 02 '18 at 04:17
  • Can't you use jquery selectors to select all the inputs in the form? Something like `$("#formid input")`? – H77 Apr 02 '18 at 04:20

1 Answers1

0

Changes in the value of input don't automatically fire the .change() event. So, wherever it is that you're setting that value, you also have to tell jQuery to trigger it.

$('selector').val(myValue).trigger('change');
nyn05
  • 540
  • 5
  • 17