How to fix "Uncaught TypeError: learnmore.forEach is not a function"?

Trying to write a function to call the modal window.
<div class="description-btn"> Learn more</div>

let learnmore = document.getElementsByClassName('.discription-btn');

 el.addEventListener('click', function(){ = 'block';
this.classList.add('more-splash'); = 'hidden'; // block scrolling body with an open MO 

And of course the output (to click) have the error "Uncaught TypeError: learnmore.forEach is not a function". Why? How to do it properly?
April 3rd 20 at 18:34
3 answers
April 3rd 20 at 18:36
Because the function returns not an array, but forEach is a method of the prototype array.

  • To substitute for querySelectorAll, getElementsByClassName, then you will get an object of type NodeList, the prototype of which is fofEach.

  • To turn your fairway object to an array using the spread operator, or method Array.from.

  • To delegate the event.

  • To sort through for.
not working!(( - rosalyn_Casper commented on April 3rd 20 at 18:39
more precisely, the error is gone) the window doesn't appear) - rosalyn_Casper commented on April 3rd 20 at 18:42
April 3rd 20 at 18:38
April 3rd 20 at 18:40
let learnmore = document.getElementsByClassName('discription-btn');

Find more questions by tags JavaScript