<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Title</title>
<style>
input {
color: #ccc;
}
</style>
</head>
<body>
<input type="text" value="手机">
<script>
var a = document.querySelector('input')
a.onfocus = function () {
if (a.value === '手机') {
a.value = ''
}
a.style.color = '#333'
}
a.onblur = function () {
if (a.value === '') {
a.value = '手机'
}
a.style.color = '#ccc'
}
</script>
</body>
</html>
黑马js仿京东文本框
最新推荐文章于 2024-07-12 16:27:40 发布