JSFiddle - React, Tailwind, and code Playground

HTML

<div>sometext<a href="#">delete</a></div>

JavaScript

$("a").click(function(){
var text = $(this).parent().clone()    //clone the element
        .children() //select all the children
        .remove()   //remove all the children
        .end()  //again go back to selected element
        .text();
    alert(text);
});