.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. 269. Alien Dictionary 另类字典 *HARD*

    There is a new alien language which uses the latin alphabet. However, the order among letters are un ...

  2. mybatis if test 不为空字符串或null

    <if test="type !=null and type !=''"> AND l.type=#{type,jdbcType=INTEGER} </if> ...

  3. Java中sql语句的引号问题

    1..sql语句 在数据库中,当我们查询语句时,会使用类似的语句: Select * from userinfo where userid='1' or 1; Select * from userin ...

  4. ldconfig和ldd用法

    一.ldconfig ldconfig是一个动态链接库管理命令,为了让动态链接库为系统所共享,还需运行动态链接库的管理命令--ldconfig. ldconfig 命令的用途,主要是在默认搜寻目录(/ ...

  5. WCF初探-25:WCF中使用XmlSerializer类

    前言 在上一篇WCF序列化和反序列化中,文章介绍了WCF序列化和反序列化的机制,虽然WCF针对序列化提供了默认的DataContractSerializer序列化引擎,但是WCF还支持其他的序列化引擎 ...

  6. 【 2013 Multi-University Training Contest 5 】

    HDU 4647 Another Graph Game 如果没有边的作用,显然轮流拿当前的最大值即可. 加上边的作用,将边权平均分给两个点,如果一个人选走一条边的两个点,就获得了边的权值:如果分别被两 ...

  7. string类实现(C++)

    class CMyString { friend std::ostream& operator<<( std::ostream& os, const CMyString&a ...

  8. android 混淆导致友盟反馈出错

    最近混淆应用时出现了一个错误: 打包编译没问题,但程序运行之后,点击友盟的反馈就会导致程序报错: E/AndroidRuntime(7669):  java.lang.RuntimeException ...

  9. SQL基础&笔试题

    仅以此篇博客纪念让我羞愧的一次笔试,作为对数据库基础的恶补. 一.SQL的基本概念: SQL是集数据定义语言DDL,数据操纵语言DML,数据控制语言DCL的功能于一体,可以独立完成数据库生命周期的全部 ...

  10. CSS-position详解

    position属性 position属性可以调整DOM元素在浏览器中的位置,能够很好的体现HTML普通流这个特征.重点在于应用了不同的position值之后是否有脱离普通流和改变Display属性这 ...