Trigger a button when enter a button
<p>I am trying to append divs into another divs. That works fine. Here I need some helps, In the below code there is a div with content editable and a save and close button. When i click the save button that was append to the div. But I need make the button clickable when I press the Enter Button. </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function createNewList(listName) {
  var cardNameFieldElement = $('&lt;div class = "card-name-field" onkeydown=\'cardSave\' style = "white-space : normal; width: 240px; min-height: 60px; border-radius: 3px; margin-left: auto; margin-right: auto; background-color: #ffffff;  " contenteditable = "true" data-placeholder = "Add a Card..."  &gt;&lt;/div&gt;');
  var saveCloseCardWrapper = $('&lt;div class ="save-close-card-wrapper" style = "width: 250px; height: 35px;  margin-top: 5px;"&gt;  &lt;input class = "save-card" id = \'SAVE_CARD_BTN\' onclick = \'saveNewCard($(this))\' type="button" value="Save" style = "cursor: pointer; width: 60px; height: 30px; background-color: gray; border-color: gray; margin-left: 10px; border-radius: 3px; vertical-align: top;"&gt;&lt;img class = "close-card-create" onclick = \'closeCard($(this))\' src = "media/icons/close.png" width="25" height="25" style = "cursor: pointer; margin-top: 4px; margin-left: 3px;"&gt;&lt;/div&gt;');
}

function saveNewCard(saveCard) {
  var parent = saveCard.closest('.board-list');
  var cardName = parent.find('.card-name-field').text();
  if (cardName !== "") {
    var cardNameElement = $('&lt;div class = "card-name"&gt;' + cardName + '&lt;/div&gt;');
    cardNameElement.insertBefore(parent.find('.create-card-section'));
    parent.find('.card-name-field').html("");
  }
}</code></pre>
</div>
</div>
</p>

<p>Please look the code and give me some help. I tried this method, but it doesn't work. </p>

<pre><code>$(".card-name-field").keyup(function(e) {
  if (e.keyCode == 13) {
    $(".save-card").click();
  }
});
</code></pre>