Here is probably the best solution:
var buttons = $("sup");
for(var i=0; i< buttons.length; i++){
if (buttons[i].children[0]) {
if (buttons[i].children[0].nodeName == "SPAN") {
var spanElement = buttons[i].children[0];
buttons[i].setAttribute("class", spanElement.getAttribute("class"));
buttons[i].innerHTML = spanElement.innerText;
}
}
}
This selects every sup
element, and checks whether there is a span
within it. If there is a span
element, then it sets the sup
element's class to the span
's class, and sets the innerHTML to the span
's innerText.
I hope that makes sense.
If you need the JQuery library, then I recommend using jquery-3.2.1.min.js.