I'm experiencing this trouble with jQuery and attr() function.
Take a look:
one <input id='one' type="text"><br>
two <input id='two' type="text">
<script>
$('#one').on('input',
function(){
var result = 'test'
$('#two').attr('value',result);
}
);
</script>
This is the trouble:
- I type something in the 'one' input;
- the 'test' text was correctly inserted in the 'two' input.
- Now I edit the content of the 'two' input.
- Now if I type something new in the 'one' input , the 'two' input content isn't replaced with the 'test' text ! Why ?! How can I fix it ?
P.S. See the live code here http://jsfiddle.net/5XQJj/4/