Created
April 4, 2018 23:31
-
-
Save liseferguson/a951459135c8dbacd56d8226ba37d2d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$('#js-shopping-list-form)').submit(function(event){ | |
event.preventDefault(); | |
const newItem = $('js-shopping-list-entry').val(); | |
$('.js-shopping-list-entry').val(''); //what is the empty ('') | |
$('.shopping-list').append( | |
`<li> | |
<span class="shopping-item">${newItem}</span> | |
<div class="shopping-item-controls"> | |
<button class="shopping-item-toggle"> | |
<span class="button-label">check</span> | |
</button> | |
<button class="shopping-item-delete"> | |
<span class="button-label">delete</span> | |
</button> | |
</div> | |
</li>`); | |
}); | |
//why don't these work? | |
$('.shopping-item-toggle').click(function() { | |
$(this).toggleClass("check"); | |
}); | |
$('.shopping-item-delete').click (function() { | |
$(this).remove(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment