다음 코드를 구현하는 자바 스크립트 이벤트 사용
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
</style>
</head>
<body>
<input type="text" onfocus="fun()" id="input" onblur="fun1()">
</body>
<script>
function fun() {
var input = document.getElementById('input');
input.placeholder = "请输入你的姓名";
}
function fun1() {
var input = document.getElementById('input');
if (!onkeydown){
input.placeholder = "用户名不能为空";
input.style.border = "1px solid red";
}
if (input.value != ''){
input.style.border = "1px solid #a9a9a9";
}
}
</script>
</html>
![부터](https://img2018.cnblogs.com/blog/1766320/201912/1766320-20191218215758915-332154730.gif)
입력 상자가 재미 () 함수 재미 () 함수의 구현에 초점을 얻을 때 행 세트에, ID를 사용하는 방법을 찾는 데 사용됩니다 placeholder
에 "당신의 이름을 입력하세요."