1

I have an input box on a form and I want to fire an event when the value of that input changes. The value is typically changed through some other jQuery function and the .change() event does not appear to be triggered when this happens.

How can I make this possible?

1
  • It should work buddy, unless for first attempt when you write something into the test box. Commented May 10, 2013 at 14:01

2 Answers 2

3

You need to fire the change event manually

Ex:

$('<selector>').val('<value>').trigger('change')
Sign up to request clarification or add additional context in comments.

7 Comments

But my script does not have any other relation to the other script that is triggering the change
@MartyWallace Then there isn't much you can do, but it doesn't make sense for that to be a problem. There's no reason you can't add .change() to it after calling .val(value), it's still decoupled from whatever is listening for that change event.
@MartyWallace in that case I think you are out of luck
So it is not possible to monitor a form input for changes? I mean, i would have thought that some event would be fired regardless of how the input is value is changed?
@MartyWallace Sure, it's possible, but you have to trigger said event yourself.
|
1

Use that

$("element").trigger("change");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.