dany994,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.active {
background-color: #FF0000
}
</style>
<script>
const start = () => alert("1");
document.addEventListener("click", ({ target }) => {
target = target.closest("[data-id]");
if (target) {
if (target.classList.contains("test")) start();
let id = target.dataset.id;
target = document.getElementById(id)
if (target) target.classList.add("active")
}
})
</script>
</head>
<body>
<div data-id="p1" class="test">1</div>
<div data-id="p1">1</div>
<div data-id="p1">1</div>
<div data-id="p2">2</div>
<div data-id="p3">3</div>
<div data-id="p3">3</div>
<div id="p1">1</div>
<div id="p2">2</div>
<div id="p3">3</div>
</body>
</html>