document.querySelector('.black-bg').addEventListener('click', function() {
document.querySelector('.black-bg').classList.remove('show-modal');
});
<div class="black-bg">
<div class="white-bg">
e.target;
e.currentTarget;
e.preventDefault();
e.stopPropagtion();
document.querySelector('.black-bg').addEventListener('click', function(e) {
console.log(document.querySelector('.black-bg'))
if (e.target == document.querySelector('.black-bg')){
document.querySelector('.black-bg').classList.remove('show-modal');
}
var buttonSelector = $('.tab-button')
for (let i = 0; i < 3; i++) {
buttonSelector.eq(i).on('click', function() {
openTab(i);
});
}
function openTab(index){
buttonSelector.removeClass('orange');
buttonSelector.eq(index).addClass('orange');
buttonSelector.removeClass("show");
buttonSelector.eq(index).addClass('show');
}
<ul class="list">
<li class="tab-button">Products</li>
<li class="tab-button orange">Information</li>
<li class="tab-button">Shipping</li>
</ul>
$('.list').click(function(e) {
if (e.target == document.querySelector('.tab-button')[0]) {
openTab(0);
} else if (e.target == document.querySelector('.tab-button')[1]) {
openTab(1);
} else {
openTab(2);
}
})
function openTab(index){
buttonSelector.removeClass('orange');
buttonSelector.eq(index).addClass('orange');
buttonSelector.removeClass("show");
buttonSelector.eq(index).addClass('show');
}
<div class="container mt-5">
<ul class="list">
<li class="tab-button" data-id="0">Products</li>
<li class="tab-button orange">Information</li>
<li class="tab-button">Shipping</li>
</ul>
$('.list').click(function(e) {
openTab(e.target.dataset.id);
});
var buttonSelector = $('.tab-button')
function openTab(index){
buttonSelector.removeClass('orange');
buttonSelector.eq(index).addClass('orange');
buttonSelector.removeClass("show");
buttonSelector.eq(index).addClass('show');
}