You need to use $('#inputText').keyup();
since you want to run it when the key is released.
get value of textarea html in javascript
-
24-06-2023 - |
Question
I have a textarea
<textarea id='inputText' rows='30' style="width: 45%; margin-left: 20%;">
and in Javascript when I press a key a send the value of the textare
$('#inputText').keypress(function (e){
conn.send($('#inputText').val());
}
my problem is that when I press a key it sends the previous state of the textare. Is there a way where I can "refresh" the textarea value before sending it?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow