MathMLElement:blur() 方法
MathMLElement
接口的 blur()
方法将键盘焦点从当前的 MathML 元素上移除。
语法
js
blur()
参数
无。
返回值
无(undefined
)。
示例
从 MathML 元素上移除焦点
HTML
html
<div>
<math>
<msup id="myMath" tabindex="0">
<mi>x</mi>
<mn>2</mn>
</msup>
</math>
<button id="focusButton">Focus the Math</button>
<button id="blurButton">Blur the Math</button>
</div>
JavaScript
js
const mathElement = document.getElementById("myMath");
const focusButton = document.getElementById("focusButton");
const blurButton = document.getElementById("blurButton");
// Focus the MathMLElement when the "Focus" button is clicked
focusButton.addEventListener("click", () => {
mathElement.focus();
});
// Blur the MathMLElement when the "Blur" button is clicked
blurButton.addEventListener("click", () => {
mathElement.blur();
});
结果
规范
规范 |
---|
HTML # dom-blur-dev |
浏览器兼容性
加载中…