JSFiddle - React, Tailwind, and code Playground
by Thanos Saringelos
HTML
<div>
<span>[email protected]</span>
<button onclick="myFunction(this)">delete me!</button>
</div>
<div>
<span>[email protected]</span>
<button onclick="myFunction(this)">delete me!</button>
</div>
<div>
<span>[email protected]</span>
<button onclick="myFunction(this)">delete me!</button>
</div>
JavaScript
function myFunction(randomDeleteBTN){
let spans = randomDeleteBTN.parentNode.getElementsByTagName("span");
console.log(spans[0].innerHTML)
}