3

I have a textbox whose text is expected to be changed from the jquery code.

It is not firing when the value assinged from jquery code however it is firing when I change the text by key press.

Below is HTML and JQuery which i am using

<input type="text" id="txtProjectName"/>
 $("#txtProjectName").on('change keyup paste mouseup', function () {
        alert('Changed');
    });

What modifications would require here? please assist.

1 Answer 1

5

It is not firing when the value assinged from jquery code

Programmatically changing the value of an input doesn't fire its change event. You'll have to do that yourself using .trigger()

You need need to trigger change event when changing value from code

 $("#txtProjectName").val('Whatever').trigger('change');
Sign up to request clarification or add additional context in comments.

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.