input框内默认文字点击消失
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function addLoadEvent(func){
var oldonload = window.onload;
if(typeof window.onload!= 'function' ){
window.onload = func;
}
else{
window.onload = function(){
oldonload();
func();
}
}
}
var inputtext = function(){
var inputs = document.getElementsByTagName('INPUT');
for(var i=0; i<inputs.length; i++){
var str = "gray_input";
if(str.indexOf(inputs[i].className)==-1) continue;
var element = inputs[i];
element.onfocus = function() {
if (this.value == this.defaultValue) {
this.value = "";
this.className = "gray_input2";
}
}
element.onblur = function() {
if (this.value == "") {
this.value = this.defaultValue;
this.className = "gray_input";
}
}
}
} addLoadEvent(inputtext);
</script>
<style>
.gray_input{color:#878787;}
.gray_input2{color:#444;}
</style>
</head> <body>
<input name="text2" type="text" id="main_search3" class="gray_input" value="搜一下问题来回答"/>
</body>
</html>
input框内默认文字点击消失的更多相关文章
- HTML5轻松实现搜索框提示文字点击消失---及placeholder颜色的设置
在做搜索框的时候无意间发现html5的input里有个placeholder属性能轻松实现提示文字点击消失功能,之前还傻傻的在用js来实现类似功能... 示例 <form action=&quo ...
- 鼠标点击input框后里面的内容就消失
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- input框的默认bug解决办法
input框的默认bug是在没干掉边框的情况下是不能设置背景颜色的,否则边框会变成内边框(黑色)效果,很难看. 解决办法是: none掉input框的边框:border:none; 再设置其背景色为任 ...
- 设计input搜索框提示文字点击消失的效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 消除input框的默认样式
input, button, select, textarea { outline: none; -webkit-appearance: none; border-radius: 0; } outli ...
- 类似input框内最右边添加图标,有清空功能
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- input内文字点击消失 弹出层,可以写表单
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- js实现鼠标点击input框后里面的内容就消失代码
<!--# <a href="http://www.mianfeimoban.com/texiao_mb/" target="_blank" cla ...
- ECSHOP搜索框文字点击消失
<input name="keywords" type="text" id="keyword" value="黄山金银币&q ...
随机推荐
- HTML基本操作
插入图片: 1.利用链接(静态) <img src="http://www.kmwzjs.com/useruploads/images/20101020_057600100825157 ...
- ArchLinux安装与配置小结
最近无意间发现一个基于ArchLinux的发行版--BlackArch,主题十分炫酷(中二).当然渗透类的Linux 发行版已经有BackTrack和Kali了,不过都是源于Debian的,使用者众多 ...
- 【转】SIP 中的Dialog,call,session 和 transaction
如果你对Sip协议中Call, Dialog, Transaction和Message之间的关系感觉到迷惑,那么,那么我可以告诉你,你并不孤单,因为大多数初学者对于这些名词之间的关系都会感到疑惑. ...
- 【golang】用container/list实现栈(Stack)
go语言中的container有heap.list.ring,没有stack. 其中heap是优先级队列,虽然有Push()/Pop()接口,但是使用heap要实现heap.Interface接口,不 ...
- 308. Range Sum Query 2D - Mutable
题目: Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper ...
- XML文件操作学习(一)
受人启发,从今天开始也把学到的东西记在博客里加深印象,并且完成这个梳理过程. 最近大多数的时间都花费在做系统配置上了.大部分的配置比较复杂的都用xml文件来存储.暂时发现有以下几点需要注意的地方. 今 ...
- spring springmvc mybatis 整合
环境 apache-tomcat-8.0.33.jdk1.8.0_05 maven Dynamic Web Module 2.5 1.各个xml配置文件的配置 (1)pom.xml 配置清单文件 连接 ...
- 转: $GLOBALS['HTTP_RAW_POST_DATA'] 和$_POST的区别
$_POST:通过 HTTP POST 方法传递的变量组成的数组.是自动全局变量. $GLOBALS['HTTP_RAW_POST_DATA'] :总是产生 $HTTP_RAW_POST_DATA 变 ...
- c#对文件进行MD5加密校验
public static string GetFileMd5Hash(string strFileFullPath) { // Create a new instance of the MD5Cry ...
- linux 实时时钟(RTC)驱动【转】
转自:http://blog.csdn.net/yaozhenguo2006/article/details/6820218 这个是linux内核文档关于rtc实时时钟部分的说明,此文档主要描述了rt ...