<!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>
<style>
input{
outline: none;
color: #999;
}
div{
width: 200px;
height: 50px;
border: 1px;
border-style:solid dashed dashed;
display: none;
font-size: 20px;
}
</style>
</head>
<body>
<div></div>
<input type="text" value="iphone 13">
<script>
var div=document.querySelector('div')
var text=document.querySelector('input');
text.addEventListener('focus',function(){
if(this.value=='iphone 13'){
this.value='';
}
this.style.color='#333';
})
text.addEventListener('blur',function(){
if(this.value==''){
this.value='iphone 13';
}
this.style.color='#999'
})
document.addEventListener('keyup',function(e){
if(e.keyCode==83){
text.focus();
}
})
text.addEventListener('keyup',function(e){
if(this.value==''){
div.style.display='none'
}else{
div.style.display='block'
div.innerHTML=this.value;
}
})
text.addEventListener('blur',function(){
div.style.display='none'
})
text.addEventListener('focus',function(){
if(text.value!=''){
div.style.display='block'
}
})
</script>
</body>
</html>