<div>
<math>
<msup id="myMath" tabindex="0">
<mi>x</mi>
<mn>2</mn>
</msup>
</math>
<button id="focusButton">Focus the Math</button>
</div>MathMLElement: focus() method / notebook
MathMLElement: focus() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const mathElement = document.getElementById("myMath");
document.getElementById("focusButton").addEventListener("click", () => {
mathElement.focus();
});