-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (29 loc) · 1.01 KB
/
Copy pathscript.js
File metadata and controls
32 lines (29 loc) · 1.01 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
$(document).ready(function () {
$('.newTask').val('');
var i = 0;
for(i;i<localStorage.length;i++)
{
$('.tasks').html("<button class='taskItem' >"+localStorage.getItem(localStorage.key(i))+"</button>" + $('.tasks').html());
}
$('.addBtn').on('click',function(){
var newText= $('.newTask').val();
if(newText == ''){
$('.error').addClass('active');
}else{
localStorage.setItem(localStorage.length,newText);
$('.error').removeClass('active');
$('.tasks').html("<button class='taskItem' >"+newText+"</button>" + $('.tasks').html());
console.log($('.tasks').html());
}
$('.newTask').val('');
});
$('body').delegate('.taskItem','click',function() {
//$('.').on('click',function(){
$(this).addClass('line');
});
$('.clearBtn').on('click',function(){
alert('Sure ?');
$('.tasks').html('');
localStorage.clear();
});
});