.forEach((tabs) => {
tabs.querySelector('li').classList.add('tab-selected')
})
document.querySelectorAll('div[data-tabs-content]')
.forEach((tabsContent) => {
tabsContent.querySelectorAll('div:not(:first-child)')
.forEach((tabContent) => {
tabContent.style.display = 'none';
})
})
I can insert the foreach with the queryselector but then the line becomes a bit long. Also, I can save the query selector in a variable, but I don't need to cache it and it would be just useless. Is it fine like that or there are better ways to stylize it?
You can collapse nested query selectors into 1
Обсуждают сегодня