JSFiddle - React, Tailwind, and code Playground

HTML

<h1>Title <small>subheading</small> <a href="#"></a></h1>

JavaScript

var machine = $("h1")
    .clone()    //clone the element
    .children() //select all the children
    .remove()   //remove all the children
    .end()  //again go back to selected element
    .text();
alert(machine);