Modal immediately fades out on click (custom code help)

Howdy, im following an older forum post on creating a modal with custom code. Everything works fine except when I added the snippet to close the modal window by clicking on the body , it now immediately closes the modal when you click to open it :confused:

I didn’t see anyone else having this issue in the thread. Any idea what’s going on here? I’m a .js rookie.

Gif of unwanted behavior

The code:

$(document).ready(function() {
  $('.modal-link-1').click(function() {
  $('.close-modal').click(function() {
  $('body').click(function() {

Here is my site Read-Only:

When clicking the card, you’re also triggering the body click I guess? Why not remove that function and add in one for .modal-frame instead?

i tried that with modal-bg and it didnt work, when I target modal-frame, when you click on any content in the modal it closes the modal too :sweat_smile:

I solved it, had to change the modal-frame to hug the body content instead of being full width since it was sitting on top of modal-bg it wasn’t clickable.