$(document).ready(function() {
$('#text').live('change', function() {
alert('hello');
});
$('#button').live('click', function() {
$('#text').val('some text');
});
});
<div>
<input type="button" id="button" value="Click Me" />
<input type="text" id="text" />
</div>
How can I make the change function on the textbox trigger when I click the button?
You can use
.change()(the shortcut) or.trigger(), like this:Or this:
Either method works to trigger any
changeevent handlers you’ve added, you can test it here.