问题
I want to check if user changes the value of a textbox. If the user changes the value, then I want to display the changed value in a different textbox.
回答1:
jquery has an event for this, .change(), this event will detect content changes when the textbox looses focus.
If you are wanting to detect the change at every keypress, .keyup() and .keydown() might be better suited for your needs.
Examples for your intended use:
//just change '.change' to '.keyup' or '.keydown' the rest is the same.
$('input').change(function() {
$('target').val(this.value);
});
来源:https://stackoverflow.com/questions/4911832/how-to-track-change-in-textbox-using-jquery