Updating one text box as text is typed in another text box, using jQuery
I have created a webpage using HTML and jQuery. An开发者_StackOverflow中文版d I am using webpy framework. I have two text boxes in my html/webpage. I want to display the contents of first textbox in second textbox meanwhile I type in first textbox. How can I implement this using jQuery.
Try:
$("#sourceText").keyup(function () {
$("#destinationText").val($(this).val());
});
Regards
Use jQuerys Change event handler (search for jQuery Change for full docs)
Something like this should be what you are after
$(function() {
$('#txtbox1').change(function() {
$('#txtbox2').val(this.value);
});
});
EDIT - Even though this was accepted answer check out the answer provided by @Huske for a better way, both work but I thought I should point out his alternative.
精彩评论