JSFiddle - React, Tailwind, and code Playground
by 규연 황
HTML
<div class="wrap">
<p>
<button type="button">button</button>
</p>
</div>
CSS
p {
position: absolute;
}
JavaScript
const button = document.querySelector('button');
button.addEventListener('click', function(event){
console.log(event.target.offsetParent)
const target = event.target.offsetParent;
target.classList.add('active')
})