模拟placeholder效果
来源:互联网 发布:mac软件卸载不了 编辑:程序博客网 时间:2024/06/16 19:22
因为要修改默认placeholder的样式比较困难,用js模拟placeholder的效果
<!DOCTYPE HTML><html lang="zh-CN"><head> <meta charset="utf-8"> <title>模拟placeholder</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script> <style> *{margin: 0;padding: 0} div#main{ width:300px; text-align: center; } .red{ color:red; } </style></head><body> <input type="text" class="form-control red" value="请输入电话"> <script> $(function(){ $('input').focus(function(){ if($(this).val()=='请输入电话'){ $(this).toggleClass('red'); $(this).val(''); } }); $('input').blur(function(){ if($(this).val().trim()==''){ $(this).toggleClass('red'); $(this).val('请输入电话'); } }); }); </script></body></html>
0 0
- 模拟placeholder效果
- textarea模拟placeholder效果
- 模拟placeholder效果
- HTML5 placeholder JS模拟
- textView实现placeholder效果
- 浏览器PlaceHolder效果
- ios UITextView placeHolder效果
- 实现UITextView的placeholder效果
- 【转】placeholder属性模拟插件(兼容IE)
- UITextView加上placeholder效果用UILabel
- UITextView设置类似placeholder的效果
- js实现html的placeholder属性效果
- 自定义一个具有placeholder效果的textView
- placeholder效果适配IE8(1)
- placeholder效果适配IE8(2)
- placeholder效果适配IE8(3)
- jQuery实现IE浏览器兼容placeholder效果
- 自己给 TextView 添加 placeholder效果
- hdu 5583 Numbers
- CAFFE 在windows平台的使用
- php://filter漏洞利用实例
- curl模拟post请求提交
- Git分支管理
- 模拟placeholder效果
- TCP协议与UDP协议的定义与区别
- mysql插入数据,获取最新插入的ID(自增列)
- 盾神与条状项链
- Centos搭建docker环境
- Hibernate深入Session
- 欢迎使用CSDN-markdown编辑器
- 胡侃软件开发之C#的委托
- 计算文件的 MD5 值