1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $('input[name="mybutton"]').click(function(){ var textal = $("#mybox").val(); $("#mydiv").append(textal+'<br/>'); }); $('#my_textbox').keypress(function (click_event) { var key = click_event.which; if(key == 13) { $('input[name=mybutton]').click(); return false; } }); }); </script> </head> <body> <div id="mydiv"></div> <input type="text" id="my_textbox"> <input type="button" name="mybutton" id="mybutton" value="Click" > </body> </html> |