T
T
Type Programmer2020-05-12 19:11:07
JavaScript
Type Programmer, 2020-05-12 19:11:07

How to separate two sections of code in html so that they do not interfere with each other?

I have two product cards on my site. Each card has a picture, when you click on it, a modal window opens. But when I add two product cards, the modal doesn't open. How can two sections of code (two cards) be separated so that they do not interact together?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ivanov, 2020-05-12
@aschurf

Bring it on

$('.card-img').click(function () {
    $('.modal-bg').toggle(50);
    $('.modal-bask-btn').click(function () {
      $('.modal-bg').hide();
    });
  });

to the mind
$('.card-img').click(function () {
    $('.modal-bg').modal('show');
  });

L
Lord_Dantes, 2020-05-15
@Lord_Dantes

Make it so that when you click on card-img in functions, open parameters with this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question