-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.js
More file actions
40 lines (34 loc) · 1.35 KB
/
main.js
File metadata and controls
40 lines (34 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$(document).ready(function(){
//to add elements in to be done list
$("#Add").click(function(e){
if($("#taskEntered").val() === ""){//checking empty or not
alert("Error : No Task Entered");
return false;
}
else{
var taskAdded = $("#taskEntered").val();//taking input task from textbox
$("#to-be-done").append("<div class='row well l_property'>" + "<div class='col-xs-1'>" + "<input class='check_todo' type='checkbox' name='completed'>" + "</div>" + "<div class='col-xs-10'>" + "<h4>" + taskAdded + "</h4>" + "</div>" + "<div col-xs-1>" + "<button title='Remove from list ' class='btn btn-default btn-danger' id='removeBtn'><b>Remove</b></button>" + "</div>");
$("#addForm")[0].reset();//to reset textbox
e.preventDefault();//to prevent form reset
}
});
//Remove element from list
$(document).on('click', '#removeBtn',function(){
var taskDel = $(this).parent().parent();
$(taskDel).remove();
});
//moving checked task to 'done' list
$("#to-be-done").on('click', '.check_todo' ,function(){
if($(this).is(':checked')){
var parentEle =$(this).parent().parent();
$(parentEle).appendTo("#done");
}
} );
//moving uncheck task to 'to-be-done' list
$("#done").on('click', '.check_todo' ,function(){
if(!($(this).is(':checked'))){
var parentEle =$(this).parent().parent();
$(parentEle).appendTo("#to-be-done");
}
} );
});