Similar to Stack Overflow, I'm trying to create a jquery method that records and displays the value of what a user enters into an <input type='text'> field.
<form>
Language:</br>
<input type="text" language="language">
<input type="submit" value="submit">
</form>
<p>
</p>
<script>
$(document).ready(function () {
$(":text").keypress(function () {
$("p").text($(":text").val());
});
});
</script>
It accurately records the correct value, but it is one step too slow. If I type in a first character, it doesn't show up, but after I type in a second character, only the first character is recorded. If I type in 3 characters, the first 2 are recorded, etc.
How can I fix this?