仿淘宝搜索框 -- 输入内容隐藏默认文本
来源:互联网 发布:笨方法学python在线 编辑:程序博客网 时间:2024/06/07 01:19
在线演示
html:
<div id="search"> <input type="text" id="txt"> <label for="txt" id="message">必败的国际大牌</label> <button>搜索</button></div>
css:
<style> input, button { /*去除默认样式*/ border: none; padding: 0; margin: 0; outline-style: none; /*去除input蓝色外边框*/ } input { vertical-align: middle;/*兼容IE8居中显示*/ padding-top: 0; padding-bottom: 0; font-family: "SimSun", "宋体"; } #search { width: 538px; height: 75px; position: relative; margin: 100px auto; } input { width: 450px; height: 32px; border: 2px solid red; padding-left: 4px; line-height: 32px; font-size: 16px; color: #666; float: left; font-weight: 400; } label { font-size: 16px; color: #ccc; line-height: 32px; position: absolute; left: 10px; top: 3px; cursor: text; } button { width: 80px; height: 36px; background-color: red; color: #fff; float: left; font-size: 16px; cursor: pointer; }</style>
js:
<script> function $(id) {return document.getElementById(id);} // 检测用户表单输入内容 oninput是大部分浏览器支持 onpropertychange支持IE6、7、8 $("txt").oninput = $("txt").onpropertychange = function() { if (this.value == "") { $("message").style.display = "block"; } else { $("message").style.display = "none"; } }</script>
0 0
- 仿淘宝搜索框 -- 输入内容隐藏默认文本
- 仿淘宝搜索框
- Javascript小案例(一):仿淘宝搜索框用户输入事件的实现
- oninput/ onpropertychange仿淘宝搜索框
- 仿淘宝支付密码输入框
- 仿淘宝输入框(JavaScript+html)
- android随笔25——搜索框输入内容后界面的隐藏逻辑
- 仿淘宝搜索框之---ie9以下版本placeholder效果
- zencart如何修改搜索框默认文本
- zencart如何修改搜索框默认文本
- 文本输入框默认不获取焦点
- 仿淘宝右侧导航栏显示隐藏
- js搜索文本内容
- 让输入框显示默认内容
- 设置输入框默认文字内容
- 仿qq搜索框,点击标题栏的显示与隐藏
- javascript 选中文本输入框的部分文本内容
- 仿百度搜索框支持拼音 输入联想
- DES加密算法全解析 by J Orlin Grabbe
- 四分位算法
- 自定义时间工具类
- c++排序函数sort(),qsort()的用法
- oracle 用户权限批量授予
- 仿淘宝搜索框 -- 输入内容隐藏默认文本
- ReactNative使用TabBar报错react.children.only expected to receive a single react element child
- H264格式
- Redis学习---初级篇,安装与配置
- Android Logcat
- 异或运算xor
- struts2如何从一个Action转到另外一个Action
- jstat命令详解
- 简捷的python