正常的写法

<input type="text" placeholder="占位符">

这种写法ie低版本的支持不友好,为了满足某些测试或者产品的变态需求,又要改默认字体颜色,又要兼容各版本浏览器,只有使出杀手锏了,利用js的onfocus和onblur事件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .clo1{color:red;}
    </style>
</head>
<body>
    <input type="" class="clo1" onfocus="if(this.value=='您的电话'){this.value='';this.className=''}" onblur="if(this.value==''){this.value='您的电话';this.className='clo1';}" value="您的电话" name="">
</body>
</html>

 

相关文章:

  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2021-08-10
  • 2021-11-29
猜你喜欢
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
相关资源
相似解决方案