Tell me, please, how to make it so that once again not to write calls modalki, by type:
$('#button-1').on('click', function() { $('#modal-1').addClass('j-modal--open'); }); $('#button-2').on('click', function() { $('#modal-2').addClass('j-modal--open'); });
and so on, and write something like this:
var modal__id = $('a[href^="#j-form"]').val(); $('a[href^="#j-form"]').on('click', function() { $(modal__id).addClass('j-modal--open'); });
Where the contents of href are entered into a variable and when clicking on a link, there is an id with the same name and the j-modal class is added to it - open
That is, when you click:
<a href="#j-form__какой-то-id">Нажать тут</a>
The window opened:
<div id="j-form__какой-то-id">Контент модалки</div>