Здравствуйте, написал табы, не могу понять, почему не идет клик на само изображение
<div class="tabs__nav">
<a class="tabs__link" href="#content-1"><img src="/wp-content/uploads/2021/01/music-lamp-ic.png">MUSIC LAMP</a>
<a class="tabs__link" href="#content-2"><img src="/wp-content/uploads/2021/01/posters_ic.png">POSTERS</a>
<a class="tabs__link" href="#content-3"><img src="/wp-content/uploads/2021/01/led-lamp-ic.png">LED LAMP</a>
<a class="tabs__link" href="#content-4"><img src="/wp-content/uploads/2021/01/build-blocks-ic.png">BUILDING BLOCKS</a>
</div>
var $tabs = function (target) {
var
_elemTabs = (typeof target === 'string' ? document.querySelector(target) : target),
_eventTabsShow,
_showTab = function (tabsLinkTarget) {
var tabsPaneTarget, tabsLinkActive, tabsPaneShow;
tabsPaneTarget = document.querySelector(tabsLinkTarget.getAttribute('href'));
tabsLinkActive = tabsLinkTarget.parentElement.querySelector('.tabs__link_active');
tabsPaneShow = tabsPaneTarget.parentElement.querySelector('.tabs__pane_show');
if (tabsLinkTarget === tabsLinkActive) {
return;
}
if (tabsLinkActive !== null) {
tabsLinkActive.classList.remove('tabs__link_active');
}
if (tabsPaneShow !== null) {
tabsPaneShow.classList.remove('tabs__pane_show');
}
tabsLinkTarget.classList.add('tabs__link_active');
tabsPaneTarget.classList.add('tabs__pane_show');
document.dispatchEvent(_eventTabsShow);
},
_switchTabTo = function (tabsLinkIndex) {
var tabsLinks = _elemTabs.querySelectorAll('.tabs__link');
if (tabsLinks.length > 0) {
if (tabsLinkIndex > tabsLinks.length) {
tabsLinkIndex = tabsLinks.length;
} else if (tabsLinkIndex < 1) {
tabsLinkIndex = 1;
}
_showTab(tabsLinks[tabsLinkIndex - 1]);
}
};
_eventTabsShow = new CustomEvent('tab.show', { detail: _elemTabs });
_elemTabs.addEventListener('click', function (e) {
var tabsLinkTarget = e.target;
if (!tabsLinkTarget.classList.contains('tabs__link')) {
return;
}
e.preventDefault();
_showTab(tabsLinkTarget);
});
return {
showTab: function (target) {
_showTab(target);
},
switchTabTo: function (index) {
_switchTabTo(index);
}
}
};
$tabs('.tabs');