如何在 HTML 中当元素失去焦点时执行脚本?
使用 onblur 属性,在 HTML 中当元素失去焦点时执行脚本。你可以尝试运行以下代码来实现 onblur 属性 −
示例
<!DOCTYPE html>
<html>
<body>
<p>Type text below!</p>
Country: <input type = "text" name = "myid" id = "myid" onblur = "display()">
<script>
function display() {
var str = document.getElementById("myid");
str.value = str.value.toUpperCase();
}
</script>
</body>
</html>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP