which event raised when set value of input in javascript

when set value of input in javascript which event raised? i tried these event :(propertychange change keypress paste focus textInput input keyup keydown change) for example:

$('input').live/bind/on('which event', function() {
    //...
});
$('input')[0].value = "sd";

Answers:

Answer

When you set the value programmatically no event will be raised. You can raise it yourself though:

$('input')[0].value = "sd";
$('input').first().trigger("change");

Or just using jQuery:

$('input').first().val("sd").trigger("change");
Answer

You can do something like this. You have to explicitly call change event.

$('input').val('New Value').change();
Answer

When a value is changed via a script the change event is not fired, if you want to run a handler then you can trigger the event manually

$('input').eq(0).val("sd").trigger('change');

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.