仿淘宝搜索框之---ie9以下版本placeholder效果
来源:互联网 发布:win10引导 ubuntu 编辑:程序博客网 时间:2024/06/06 20:04
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>仿淘宝搜索框</title><style>.search{width: 300px;height: 30px;margin: 100px auto;position: relative;}.search input {width: 200px;height: 25px;}.search label{font-size: 12px;color: #CCCCCC;position: absolute;top: 8px;left: 10px;cursor: text;}</style><script type="text/javascript">window.onload = function(){function $(id){return document.getElementById(id);}$('txt').focus();$('txt').oninput = $('txt').onpropertychange = function(){if(this.value == ""){$('message').style.display = 'block';} else {$('message').style.display = 'none';}}}</script></head><body><div class="search"><input type="text" id="txt" /><label for="txt" id="message">puma女鞋</label></div></body></html>
打开页面,搜索框中就可以看到灰色字体“puma女鞋”并自动获取光标。点击输入,灰色字消失。清空文本框的所有内容,灰色字自动恢复。
判断用户输入的事件有 oninput 和onpropertychange 。由于浏览器兼容的问题,他们出现的场合有所不同。 正常浏览器支持oninput ,而 IE6、IE7、IE8 支持的 onpropertychange 。
阅读全文
0 0
- 仿淘宝搜索框之---ie9以下版本placeholder效果
- 在ie9以下的版本placeholder显示
- ie9以下placeholder兼容
- jquery 解决ie9及以下版本不支持placeholder属性
- placeholder在浏览器ie9以下不支持之一种解决方法
- 仿淘宝搜索框
- Ie9以下的input输入框placeholder属性兼容方案
- 解决ie9以下input 无placeholder问题
- 淘宝搜索框效果
- ie8及其以下版本兼容性问题之placeholder实现
- h5兼容ie9以下版本
- oninput/ onpropertychange仿淘宝搜索框
- 简单实现IE9及以下对placeholder的兼容性
- 仿bilibili搜索框效果
- IE9版本以下ajax 跨域问题解决
- IE9 以下版本浏览器兼容html5
- 让IE9以下版本支持HTML5
- IE9及以下版本检测提示升级
- leetcode(2):Add Two Numbers
- 解决MyBatis进行数据库操作时因参数过长导致打印日志过长的问题
- 采用POI技术进行大数据导入
- java后台post请求
- kafka集群搭建和使用Java写kafka生产者消费者
- 仿淘宝搜索框之---ie9以下版本placeholder效果
- Tortoise SVN安装
- 中间件 rpc是什么?php中流行的中间件rpc框架有哪些
- mysql 关于DATE函数的扩展
- MyBatis 注解 pagehelper 分页
- 二叉搜索树的操作集
- 《Metasploit 魔鬼训练营》05 网络服务渗透攻击
- Python3:定时发送邮件(带附件)
- 多元化---五维图