Hi, I'm trying to change the value of an input field (target) which depends on another input (source). It works well when I manually change the source value. But if I changed the source value with another button, the target value remains the same. Here's the code...
$(document).ready(function() { $('input#change').click(function() { $('input#source').attr('value', 'This is the value changed by a button'); }); $('input#source').change(function() { $('input#target').attr('value', $('input#source').attr('value')); }); }); <p>Source: <input type="text" name="target" id="source" size="60" value="" /> <input type="button" id="change" value="change source value" /></p> <p>Target: <input type="text" name="target" id="target" size="60" value="This is the original value, type something in source to change" /></p> So how could the target input detect if there's a change within the source input without manually changing it's value? Thanks