Reputation: 89
how can id="e3" can be filled if id="e2" filled by id="e1"?
checking live code here, http://jsfiddle.net/eHEtV/
jQuery(document).ready(function(){
jQuery('#e1').on('keyup', function(){
var text = jQuery(this).val();
jQuery(this).next().val(text);
});
jQuery('#e2').on('keyup', function(){
var text = jQuery(this).val();
jQuery(this).next().val(text);
});
});
<input id="e1" value="" />
<input id="e2" value="" />
<input id="e3" value="" />
Upvotes: 1
Views: 117
Reputation: 1842
You could simplify your code since the event handler is identical for both inputs:
jQuery(document).ready(function(){
jQuery('#e1, #e2').on('keyup', function(){
var $el = jQuery(this);
$el.next().val($el.val()).trigger('keyup');
});
});
Updated JSFiddle :http://jsfiddle.net/thefrontender/eHEtV/3/
Upvotes: 0
Reputation: 3302
You can add .trigger('keyup')
to trigger the event on #e2
like this:
jQuery('#e1').on('keyup', function(){
var text = jQuery(this).val();
jQuery(this).next().val(text).trigger('keyup');
});
Upvotes: 2