Reputation: 1047
For some reason this code doesn't post when i press enter i am unable to figure out why i have layed out my Index and jquery file Please Help
index.php
<div id="display_box">
<b> MESSAGE</b>
<hr />
</div>
<div id="message_box">
<textarea id="message">
</textarea>
</div>
</div>
Jquery code
$(document).ready(function{
$('#message').keyup(function(e){
if(e.keyCode == 13){
var value =$(this).val();
$('#display_box').append(value + "<hr/>");
$('this').val('');
}
});
});
Upvotes: 0
Views: 44
Reputation: 629
replace $(document).ready(function{ with
$(document).ready(function(){
Upvotes: 1
Reputation: 23816
You have error here, You missed ()
$(document).ready(function(){
^^
Check console:
Uncaught SyntaxError: Unexpected token {
Also $('this').val()
should be $(this).val()
Upvotes: 4