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






Comments

Post a Comment

Popular posts from this blog

Php Form validation with Error messages with Checking fields.

Simple calculator using JQuery and HTML..

how to customize dashboard in active admin gem in rails 4