How do I make the same function for different actions?

  • 0
    I have a code like this
    Different code opens and closes modals.
    I wanted to combine it into a function and substitute it, but I get an error on line 25.
    I don't know how to fix it.
    Line 19 each - working code.

    I took the code itself from here -
    JavaScript Eliot Harrington, Aug 1, 2020

  • 2 Answers
  • 0
    slightly tweaked


  • 0
    Lana , I didn't understand what kind of data-img you have, so I replaced the markup, believing that this is also a modal:


Your Answer
To place the code, please use CodePen or similar tool. Thanks you!