//列表框输入前默认灰色字体,输内容时字体加黑
<input type="text" name="" id="user_name" placeholder="用户名/学号/手机号">
可以使用js中的焦点事件完成该功能
<script>
var text = document.querySelector(‘input‘);//获取元素
text.onfocus = function () {
if(this.value === ‘用户名/学号/手机号‘){
this.value = ‘‘;
}
this.style.color = ‘#333‘;
}
text.onblur = function () {
if(this.value === ‘‘){
this.value = ‘用户名/学号/手机号‘;
}
this.style.color = ‘#999‘;
}
</script>
原文:https://www.cnblogs.com/chenstudy/p/14800344.html