0

I'm trying to alert the innerHTML of a textarea after you type something in at. However, it keep alerting the original text inside the textarea, and not what you've typed in it.

Why is this happening, and how do I fix it?

<?php
include("ajaxLink.php");
?>

<textarea id = 'textarea' onkeydown = "alertContent(event)">
Hello World!
</textarea>

<script>

function alertContent(event) {

var key = event.keyCode;

if (key == 13) {
var content = $("#textarea").html();
alert(content);
} //end of if (key == 13)

} //end of function alertContent();

</script>
frosty
  • 2,559
  • 8
  • 37
  • 73

0 Answers0