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?

Was it helpful?

Solution

You need to use $('#inputText').keyup(); since you want to run it when the key is released.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top