Reputation: 49
function handleClick(e) {
console.log(e.target.value)
}
<Button value={id} onClick={handleClick} id="like-button" variant="light">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" className="bi bi-heart-fill" viewBox="0 0 16 16">
<path fillRule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z" />
</svg>
<p>Like</p>
</Button>
when i click on the button i get the value id, but if i click on elements inside the button i get the value of the element that got clicked. any idea how can i get the value -id- no matter where i clicked on?
Upvotes: 1
Views: 505