praktikum

Untitled

Dec 22nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. const container = document.querySelector('.container');
  2. const songsContainer = container.querySelector('.songs-container');
  3. const addButton = container.querySelector('.input__btn_add');
  4. const resetButton = container.querySelector('.input__btn_reset');
  5.  
  6. function renderAdded() {
  7. const songs = songsContainer.querySelectorAll('.song');
  8.  
  9. if (songs.length === 0) {
  10. resetButton.setAttribute('disabled', true);
  11. resetButton.classList.add('input__btn_disabled');
  12. } else {
  13. resetButton.removeAttribute('disabled');
  14. resetButton.classList.remove('input__btn_disabled');
  15. }
  16. }
  17.  
  18. function addSong() {
  19. songsContainer.innerHTML += `
  20. <div class="song">
  21. <h4 class="song__artist">Кино</h4>
  22. <p class="song__title">Дерево</p>
  23. <button class="song__like"></button>
  24. </div>
  25. `;
  26.  
  27. renderAdded();
  28. }
  29.  
  30. addButton.addEventListener('click', addSong);
  31.  
  32. renderAdded();
Advertisement
Add Comment
Please, Sign In to add comment