0

I'm currently learning javascript and jquery. I'm having a little trouble implementing "enter button" functionality once the text field has been filled. As of right now it only works when I click the button. I would really like to be able to hit enter and have the list item submitted. I'm working with a basic UL. Here's my code and I hope that was clear!

$('#addOne').submit(function(e) {
    var value = $('#name').val();
    $('ul').append('<li>' + value + '</li>');
});
Rajdeep Dosanjh
  • 1,157
  • 1
  • 9
  • 20
Alex Blair
  • 13
  • 3

1 Answers1

0

By default the browser executes the submit event when the user hit enter in some field of form. Can you show me the page where you have that problem?

evandrolg
  • 65
  • 2
  • 10
  • honestly i was just playing around in jsbin its not a live application. I guess i should be more clear on what im doing. Its not actually a submit form button. I just want to append the ul list with what I entered in the text field to be displayed on the webpage. – Alex Blair Jan 27 '15 at 22:41
  • $("#addOne").on('keyup', function(e) { if (e.keyCode == 13) {} // enter keycode }); – evandrolg Jan 27 '15 at 23:14