显示或隐藏文本框的内容
作者:互联网
<!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>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
input{
color:skyblue;
}
</style>
</head>
<body>
<input type="text" value="请输入">
<script>
var input=document.querySelector('input');
var float=1;
input.onfocus=function(){
if(input.value=="请输入"){
input.value='';
}
input.style.color='black';
}
input.onblur=function(){
if(input.value==""){
input.value='请输入';
}
input.style.color='skyblue';
}
</script>
</body>
</html>
标签:skyblue,style,color,value,内容,文本框,var,input,隐藏 来源: https://blog.csdn.net/yxyx0614/article/details/122394719