javascript - Detect input changes and simultaneously written other input -
i have 2 input text box. want if first input alter , same time written other input.
i utilize this code. seek not working when first page open. İf page refresh 1 time, code working. , write options. codes here
$.event.special.inputchange = { setup: function() { var self = this, val; $.data(this, 'timer', window.setinterval(function() { val = self.value; if ( $.data( self, 'cache') != val ) { $.data( self, 'cache', val ); $( self ).trigger( 'inputchange' ); } }, 20)); }, teardown: function() { window.clearinterval( $.data(this, 'timer') ); }, add: function() { $.data(this, 'cache', this.value); } }; $('input').on('inputchange', function() { var container = $("div.class1").first(); $('#firstname').on('inputchange', function() { container.find("input.firstname").val(this.value); }); }); steps :
are there changes, find first kid in 1 class first class value equal changeswhat can that?
fiddle demo
for first kid utilize input:first. - :first
try snippet,
$('input#firstname').on('inputchange', function() { var container = $("div.class1").first(); container.find("input:first").val(this.value); }); javascript jquery html html5
No comments:
Post a Comment