diff --git a/index.html b/index.html index a1f181446..919f41575 100644 --- a/index.html +++ b/index.html @@ -1,102 +1,63 @@ - - Проект "Комменты" - - - - - -
- -
- - -
- -
-
-
+ + Проект "Комменты" + + + + + +
+ +
+ + +
+ +
- - - + let result = comments.pop(); + renderComments(); + }) + + function initEventListeners() { + let likeButtons = document.querySelectorAll('.like-button'); + for (let likeButton of likeButtons) { + likeButton.addEventListener('click', () => { + let numComm = likeButton.getAttribute('data-numComments'); + + if (comments[numComm].isLiked) { + comments[numComm].isLiked = !comments[numComm].isLiked; + comments[numComm].likes--; + } else { + comments[numComm].isLiked = !comments[numComm].isLiked; + comments[numComm].likes++; + } + + renderComments(); + }) + } + } + - \ No newline at end of file + \ No newline at end of file