Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
COsmic Lamba
206 PointsInteractive Web Pages with JavaScript ..Project With JQuery
Below is My Code in Jquery for the ToDO APP... I have Done Everything Except delete ...MY Element gets Deleted Before Adding Pls Help me With the Code... I have Added the Code Below:-
//ADD
//TEXT BOX ACTIVATION
$('#incomplete-tasks').on("click", ".edit", function() {
var $labels = $(this).siblings('label').text();
if ($(this).parent().hasClass('editMode')) {
$(this).parent().removeClass('editMode')
$(this).siblings('.checkbox').attr('disabled', false);
$(this).siblings('.checkbox').attr('checked', false);
var $edit_label = $(this).siblings('input[type="text"]').val()
$(this).siblings('label').text($edit_label);
} else {
if ($(this).siblings('.checkbox').prop("checked") == true) {
$(this).parent().addClass('editMode');
$(this).siblings('input[type="text"]').attr('value',$labels)
$(this).siblings('.checkbox').attr('disabled', true);
} else {
}
}
});
$('#incomplete-tasks').on("click", ".delete", function(p) {
$(this).parent().remove();
});
$('#add').click(function() {
if ($('#new-task').val() != "") {
var $list=$('<li></li>');
var $label=$('<label></label>');
var $edit=$('<input type="text">');
var $Ebtn=$('<button class="edit">Edit</button>');
var $Dbtn=$('<button class="delete">Delete</button>');
var $check=$('<input class="checkbox" type="checkbox">');
$label.text($('#new-task').val());
$list.append($check)
$list.append($label);
$list.append($edit);
$list.append($Ebtn);
$list.append($Dbtn);
$list.css('display','blocks');
$('#incomplete-tasks').append($list);
$Dbtn.click();
$Ebtn.click();
} else {
$('#new-task').css('background-color','red')
}
});