<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<body>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<section class="todo-list-wrapper mt-5">
<div class="container">
<div class="card">
<div class="card-header">
Todo list
</div>
<ul class="list-group list-group-flush"></ul>
</div>
</div>
</section>
<script>
let tasks = [
"Выучить JavaScript",
"Выучить Angular 4",
"Выучить React"
];
let ul = document.querySelector('.list-group');
function listTemplate(task) {
//create tag li
let li = document.createElement('li');
li.innerText = task;
li.className = 'list-group-item d-flex';
//create tag i
let i = document.createElement('i');
i.className = 'fas fa-trash-alt ml-auto remove-list-item removeBtns';
//append i to li
li.appendChild(i);
//return element i
return li;
}
let removeBtns = document.getElementsByClassName('removeBtns');
function generateList(tasksArray) {
clearList();
for ( let i = 0; i < tasksArray.length; i++){
let liTemplate = listTemplate(tasksArray[i]);
ul.appendChild(liTemplate);
}
setListeners();
}
function addTask(string) {
if ( !string || typeof string !== 'string') return new Error('Не передана строка');
if ( !string.length ) return new Error('Строка не должна быть пустой');
tasks.unshift(string);
generateList(tasks);
}
function clearList() {
ul.innerHTML = '';
}
function editTask(task, updtask) {
let currentTask = tasks.indexOf(task);
tasks[currentTask] = updtask;
generateList(tasks);
}
function deleteTask(task) {
let currentTask = tasks.indexOf(task);
if( currentTask !== -1){
tasks.splice(currentTask, 1);
ul.children[currentTask].remove();
} else {
console.warn('Задача не обнаружена');
}
}
function setListeners() {
//set listeners at remove btns
for ( let i = 0; i < removeBtns.length; i++){
removeBtns[i].addEventListener('click', function (e) {
console.log(this);
});
}
}
//Генерация списка при загрузке страницы
generateList(tasks);
</script>
</body>
</html>
нужного класса на корзинах не было