There is such code:
$(document).ready(function() { $(".portfolio-item").each(function(i) { $(this).find("a").attr("href", "#portfolioModal_" + i); $(this).find(".portfolio-modal").attr("id", "portfolioModal_" + i ) }); }); It assigns id links and a modal window, but the fact is that the modal is not in the current (".portfolio-item") , but in the body of the document, that is, this does not work here.
So the question is: how to do that to go back up the DOM in order to indicate the assignment of id modal window.