I am facing an issue with the "Contact Me" tab as it does not display its content when clicked. Here is the code snippet:
<body>
<ul class="tabs">
<li data-tab-target="#home" class="active tab">Home</li>
<li data-tab-target="#pricing" class="tab">Pricing</li>
<li data-tab-target="#about" class="tab">About</li>
<li data-tab-target="#Contact Me" class="tab">Contact Me</li>
</ul>
<div class="tab-content">
<div id="home" data-tab-content class="active">
<h1>Home</h1>
<p>This is the home</p>
</div>
<div id="pricing" data-tab-content>
<h1>Pricing</h1>
<p>Some information on pricing</p>
</div>
<div id="about" data-tab-content>
<h1>About</h1>
<p>Let me tell you about me</p>
</div>
<div id="Contact Me" data-tab-content>
<h1>Contact</h1>
<p>hello let me tell</p>
</div>
</div>
</body>
</html>
It seems like there is an error (Uncaught TypeError: Cannot read property 'classList' of null) in the following JavaScript code. Can you help me identify what's wrong?
const tabs = document.querySelectorAll('[data-tab-target]')
const tabContents = document.querySelectorAll('[data-tab-content]')
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const target = document.querySelector(tab.dataset.tabTarget)
tabContents.forEach(tabContent => {
tabContent.classList.remove('active')
})
tabs.forEach(tab => {
tab.classList.remove('active')
})
tab.classList.add('active')
target.classList.add('active')
})
})