<div>
<div class="elem" data-name="name-1">1</div>
<div class="elem" data-name="name-2">2</div>
<div class="elem" data-name="name-3">3</div>
</div>
document.addEventListener('click', event => {
const { target } = event;
if (target.tagName !== 'DIV'
|| !target.classList.contains('elem')) {
return;
}
console.log(target.dataset.name);
});