I am trying to execute a function every time a field changes. Just to get started, I am using a simple textarea
and a div:
<div id="text"></div>
<textarea id="stuff"></textarea>
<script type="text/javascript">
$("#stuff").keypress(function () {
$("#text").text($("#stuff").val());
});
</script>
This works, but it is always one character behind. If I type "Hello" on the textarea, the div will just say "Hell".
What am I doing wrong?