Skip to content

Commit

Permalink
Merge pull request #5 from samanthasbytes/main
Browse files Browse the repository at this point in the history
Allows items to be added via the enter button
  • Loading branch information
samanthasbytes authored Jun 4, 2024
2 parents fb20170 + 0189068 commit 6fa7710
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ function newItem() {
// 4. Reordering the items:
$('#list').sortable();

// Clears text box after adding an item:
// 5. Clears text box after adding an item:
$('#input').val('');
}

// Allows items to be added via the enter button
$('#input').on('keydown', function (event) {
if (event.which == 13) {
newItem();
}
});

// when user clicks enter from within textbox, page refreshes and list is gone // * input field was wrapped within a form element, pressing enter triggered the default behavior for form submission, causing the page to refresh
// resolved: remove form element

Expand Down
4 changes: 2 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
body {
font: normal normal 13px/16px 'Open Sans', sans-serif;
font: normal normal 16px/19px 'Open Sans', sans-serif;
background: #dfdfdf;
}

.container {
padding: 20px;
width: 300px;
width: 350px;
margin: 0 auto;
margin-top: 40px;
background: white;
Expand Down

0 comments on commit 6fa7710

Please sign in to comment.