<html>
<body>
<p>本例使用 addEventListener() 方法将 "blur" 事件附加到 input 元素。</p>
<p>请在输入字段中写一些东西,然后在字段外单击以失去焦点(blur)。</p>
<input type="text" id="fname">
<script>
document.getElementById("fname").addEventListener("blur", myFunction);
function myFunction() {
alert("Input field lost focus.");
}
</script>
</body>
</html>