<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
input {
width: 300px;
height: 50px;
margin: 200px 500px;
color: #999;
}
</style>
</head>
<body>
<input type="text" value="手机">
<script>
var ip = document.querySelector('input');
ip.onfocus = function () {
if (ip.value === '手机') {
ip.value = '';
}
ip.style.color = '#333';
}
ip.onblur = function () {
if (ip.value === '') {
ip.value = '手机';
}
}
</script>
</body>
</html>
显示隐藏文本内容
最新推荐文章于 2024-12-26 13:26:45 发布