.phcolor{ color:#999;}//css样式

function isPlaceholer(){
var input = document.createElement("input");

return "placeholder" in input;

};
function placeholder(input){

var text = input.attr('placeholder'),
defaultValue = input.defaultValue;

if(!defaultValue){

input.val(text).addClass("phcolor");
}

input.focus(function(){

if(input.val() == text){

$(this).val("");
}
});

input.blur(function(){

if(input.val() == ""){

$(this).val(text).addClass("phcolor");
}
});

//输入的字符不为灰色
input.keydown(function(){

$(this).removeClass("phcolor");
});
};

//当浏览器不支持placeholder属性时,调用placeholder函数
if(!isPlaceholer()){

$('input').each(function(){

text = $(this).attr("placeholder");

if($(this).attr("type") == "text"){

placeholder($(this));
}
});
}//结束

也有可用jquery-placeholder.js插件解决。但插件字体颜色不是灰色。

ie9 placeholder兼容的更多相关文章

  1. ie9 placeholder兼容代码方法

    function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r ...

  2. IE9以下 placeholder兼容

    //input placeholder兼容!(function ($, doc, win) { $.fn.placeholder = function () { var i = doc.createE ...

  3. placeholder在不同浏览器下的表现及兼容方法 placeholder兼容

    1.什么是placeholder?    placeholder是html5新增的一个属性,当input或者textarea设置了该属性后,该值的内容将作为灰字提示显示在文本框中,当文本框获得焦点(或 ...

  4. placeholder兼容

    <!------------placeholder兼容-------------><script type="text/javascript">    $( ...

  5. placeholder兼容方法(兼容IE8以上浏览器)

    //placeholder兼容方法(兼容IE8以上浏览器) var JPlaceHolder = { //检测 _check: function () { return 'placeholder' i ...

  6. IE8 placeholder兼容+Password兼容

    对于placeholder兼容问题 IE系列的大部分不兼容 使用JQ插件解决这个问题,确实用法很简单 jS下载地址http://www.ijquery.cn/js/jquery.placeholder ...

  7. placeholder 兼容 IE

    placeholder 是 html5 的新属性,仅支持 html5 的浏览器才支持 placeholder,目前最新的 FF.Chrome.Safari.Opera 以及 IE10 都支持,IE6- ...

  8. ☆☆☆☆☆Placeholder兼容各大浏览器的例子☆☆☆☆☆

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  9. 关于vue+element对ie9的兼容el-upload不支持在IE9上传

    关于vue+element对ie9的兼容el-upload不支持在IE9上传 https://lian-yue.github.io/vue-upload-component/#/zh-cn/ 解决方案 ...

随机推荐

  1. Python’s SQLAlchemy vs Other ORMs[转发 6]SQLAlchemy

    SQLAlchemy SQLAlchemy is an open source SQL toolkit and ORM for the Python programming language rele ...

  2. 纯CSS tooltip 提示

    一般的tooltip,使用超链接的title,或者是css+javascript生成. 如果页面布局合理,样式结构清晰,可以使用纯CSS的提示. demo如下: a.tooltip { positio ...

  3. 《TCP/IP详解 卷1:协议》读书笔记

    第一章 概述 协议栈 应用层 HTTP,FTP   运输层 TCP, UDP 段(Segment) 网络层 IP, ICMP, IGMP 数据报(Datagram) 链路层   帧(Frame) 物理 ...

  4. 2015-01-16 .Net 中级软件工程师 笔试题

    一 C#方面 1.请简述多线程需要考虑的主要因素 答:1.线程管理 同一核上的两个线程不会以两倍的时长完成,可能需要用两倍再加10 %左右的时间来完成.与一个线程相比较的话,三个线程在同一核上想占用1 ...

  5. Android笔记——在布局文件中插入另一个布局文件

    假如有一个布局文件A.xml想把另外一个布局文件B.xml引进其布局,则可以通过下面的代码 <include layout="@layout/B" />

  6. Struts2 Result 类型和对应的用法详解

  7. 小游戏Talk表

    [Config]1|0|2|久远的记忆影子|你也是误入宠物王国的妹子吧,我在这里等你很久了,或许我们应该一起逃出这里,跟着我.[Config] [Config]2|3|2|久远的记忆影子|这里原本是一 ...

  8. [并查集] POJ 1182 食物链

    食物链 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 66294   Accepted: 19539 Description ...

  9. Sql 获取向上取整、向下取整、四舍五入取整的实例

    [四舍五入取整截取] select round(54.56,0) [向下取整截取] SELECT FLOOR(54.56) [向上取整截取]  SELECT   CEILING(13.15) --MS ...

  10. 【Python⑥】python的缩进,条件判断和循环

    缩进 Python的最大特色是用缩进来标明成块的代码. 这点和其他语言区别很明显,比如大家熟悉的C语言里: ) { num+=; flag-=; } 而在python中: if flag>= 0 ...