I am trying to get the value of each list items data- with pure JS.
const meetTheTeamSectionNames = document.querySelectorAll('.team__names li');
Array.from(meetTheTeamSectionNames).forEach(name => {
name.addEventListener('click', function(e) {
const nameMe = e.target.getAttribute('name')
console.log(nameMe);
});
});
<ul class="team__names">
<li class="current" data-name="neil">Neil Tully MW</li>
<li data-name="kevin">Kevin Rylands</li>
<li data-name="jane">Jane Coggins</li>
<li data-name="ben">Ben Green</li>
</ul>
For some reason each click returns null... and I have no idea why. Any help would be awesome :)