JavaScript中onfocusout事件的用途是什么?
onfocusin事件在元素失去焦点时触发。您可以尝试运行以下代码,以了解如何在JavaScript中实现onfocusout事件。
示例
<!DOCTYPE html>
<html>
<body>
<p>Write below:</p>
<p>After losing focus, the background color of input check will change.</p>
<input type = "text" onfocusout = "newFunc(this)">
<script>
function newFunc(x) {
x.style.background = "blue";
}
</script>
</body>
</html>