<button class="btn btn-test">click me</button>
<p class="result"></p>
const btn = document.querySelector(`.btn`);
const result = document.querySelector(`.result`);
btn.addEventListener(`click`, (e) => {
result.innerHTML = `
e.target.classList: ${e.target.classList} <br>
e.target.classList.contains('btn'): ${e.target.classList.contains('btn')} <br>
e.target.classList.contains('btn-active'): ${e.target.classList.contains('btn-active')}
`;
})
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.