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 |
瀏覽器相容性
載入中…