Skip to content

Instantly share code, notes, and snippets.

@StephenFiser
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save StephenFiser/216fb86807528958d7aa to your computer and use it in GitHub Desktop.

Select an option

Save StephenFiser/216fb86807528958d7aa to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$('#new-to-do-item').keyup(function(e) {
if (e.which === 13) {
var text = $(this).val();
var listItem = "<li><input type='checkbox'>" + text + "</li>"
$('ul').append(listItem);
}
});
$('input[type="checkbox"]').click(function() {
console.log(this);
console.log($(this));
if (this.checked) {
// or you could do if ($(this).is(":checked")) {
$(this).parent().css("background-color", "#e8e8e8");
} else {
$(this).parent().css("background-color", "#ffffff");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment