(function() {
let tabMenus = document.querySelectorAll('.js-item-link');
let tabContents = document.querySelectorAll('.tab_content');
for (var i = 0; i < tabMenus.length; i++) {
tabMenus[i].addEventListener('click', function(e) {
e.preventDefault();
for (var i = 0; i < tabMenus.length; i++) {
tabMenus[i].className = 'js-item-link';
}
this.className = 'js-item-link is-active';
for (var i = 0; i < tabContents.length; i++) {
tabContents[i].className = 'tab_content';
}
document.getElementById(this.dataset.id).className = 'tab_content is-active';
});
}
}());
<div class="modal-buy-card__tab-menu">
<button type="button" data-id="about" class="js-item-link is-active">
<span>Дата</span>
</button>
<button type="button" data-id="works" class="js-item-link">
<span>Время</span>
<span>13:00 (МСК)</span>
</button>
</div>
<div class="modal-buy-card__tab-container">
<div class="tab_content is-active" id="about">
<input class="modal-buy-card__date-calendar flatpickr flatpickr-input active" type="text" readonly="readonly">
<div>
<button>отмена</button>
<button>OK</button>
</div>
</div>
<div class="tab_content" id="works">
<p>Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works WorWorks Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works</p>
</div>
</div>
<button>OK</button> на <button onclick="obr()">OK</button>
(function() {code}()) на function obr(){}
<button type="button" data-id="about" class="js-item-link is-active">
<span>Дата</span>
</button>
<button type="button" data-id="works" class="js-item-link">
<span>Время</span>
<span>13:00 (МСК)</span>
</button>
</div>
<div class="modal-buy-card__tab-container">
<div class="tab_content is-active" id="about">
<input class="modal-buy-card__date-calendar flatpickr flatpickr-input active" type="text" readonly="readonly">
<div>
<button>отмена</button>
<button onclick="obr()">OK</button>
</div>
</div>
<div class="tab_content" id="works">
<p>Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works WorWorks Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works</p>
</div>
</div>
<script type="text/javascript">
function obr(){
alert("проверка кнопки!_!")
let tabMenus = document.querySelectorAll('.js-item-link');
let tabContents = document.querySelectorAll('.tab_content');
for (var i = 0; i < tabMenus.length; i++) {
tabMenus[i].addEventListener('click', function(e) {
e.preventDefault();
for (var i = 0; i < tabMenus.length; i++) {
tabMenus[i].className = 'js-item-link';
}
this.className = 'js-item-link is-active';
for (var i = 0; i < tabContents.length; i++) {
tabContents[i].className = 'tab_content';
}
document.getElementById(this.dataset.id).className = 'tab_content is-active';
});
}
};
</script>