How to get a text box value while press Enter Keyboard?

1. index.html <!DOCTYPE html> <html> <body> <input id="test" type="text" /> <div> <ul id="view"> </ul> </div> </body> </html> 2. JS $(document).keypress(function(e) { if(e.which == 13) { alert("Welcome"); $("#test").val(); $("#view").append($("#test").val()); } }); OUTPUT