##js练习题:搜索框内容
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<style>
input{
width: 300px;
margin: 300px;
height: 30px;
padding-left: 3px;
box-sizing: border-box;
outline: none;
outline-offset: 0;
outline-style: none;
border: 1px soldi #f40;
color: #666;
}
input::placeholder{
content: "";
color: #f40;
}
</style>
<input type="text" id="text" placeholder="搜索内容">
<script>
var search = document.getElementById('text');
search.onfocus = function(){
if(this.placeholder == '搜索内容'){
this.placeholder = '';
}
}
search.onblur = function(){
if(this.placeholder == ''){
this.placeholder = '搜索内容';
}
}
</script>
</body>
</html>