让IE支持placeholder属性~
原文:https://www.oschina.net/code/snippet_206691_26471#44160
让支持的直接路过,不支持的,完美显示~~
/* * jQuery placeholder, fix for IE6,7,8,9 * @author JENA * @since 20131115.1504 * @website ishere.cn */var JPlaceHolder = { //检测 _check : function(){ return 'placeholder' in document.createElement('input'); }, //初始化 init : function(){ if(!this._check()){ this.fix(); } }, //修复 fix : function(){ jQuery(':input[placeholder]').each(function(index, element) { var self = $(this), txt = self.attr('placeholder'); self.wrap($('<div></div>').css({position:'relative', zoom:'1', border:'none', background:'none', padding:'none', margin:'none'})); var pos = self.position(), h = self.outerHeight(true), paddingleft = self.css('padding-left'); var holder = $('<span></span>').text(txt).css({position:'absolute', left:pos.left, top:pos.top, height:h, lienHeight:h, paddingLeft:paddingleft, color:'#aaa'}).appendTo(self.parent()); self.focusin(function(e) { holder.hide(); }).focusout(function(e) { if(!self.val()){ holder.show(); } }); holder.click(function(e) { holder.hide(); self.focus(); }); }); }};//执行jQuery(function(){ JPlaceHolder.init(); });<!doctype html><html><head><meta charset="utf-8"><title>jQuery JPlaceholder Demo</title><script src="jquery-1.8.3.min.js"></script><script src="jquery.JPlaceholder.js"></script></head><body><form><div> <ul> <li> <input type="text" name="username" placeholder="用户名"> </li> <li> <input type="password" name="username" placeholder="密码"> </li> <li> <button type="button">登录</button> </li> </ul></div></form></body></html>让IE支持placeholder属性~的更多相关文章
- 让ie8支持 placeholder 属性
一. ie8支持 placeholder 属性 /* * ie8支持 placeholder 属性 */ $(function(){ if( !('placeholder' in document. ...
- input date 支持placeholder属性
第一种解决方法:IE,火狐浏览器,不支持input date的日历功能,火狐支持日历功能 ie,火狐,谷歌显示placeholder属性 css代码 #dateofday:before{ col ...
- 在IE8等不支持placeholder属性的浏览器中模拟placeholder效果
placeholder是一个很有用的属性,可以提示用户在input框中输入正确的内容,但是IE8以及IE8一下的浏览器不支持该属性,我们可以使用js来模拟相似的效果.下面直接上代码: <!doc ...
- 让ie支持placeholder属性,一段js搞定
placeholder属性真的是超级好用的新属性,可惜,只有新版浏览器才支持,为了写出输入框贴心提示,老方法就是加span标签覆盖,营造出placeholder提示的感觉,现在安利一款好用的js,好用 ...
- 基于jquery 的插件,让IE支持placeholder属性
开发一个项目的时候为了美观和用户体验用到了input标签的placeholder属性,但是这个属性是html5中的,所以低版本的IE浏览器不支持.于是在百度找了一些解决方法,找了好几个都不是那么完美, ...
- 有关ie9 以下不支持placeholder属性以及获得焦点placeholder的移除
(一)placeholder 属性起到提示客户输入信息作用 (二)ie9以下出问题了 placeholder不支持 (三)解决办法 先贴html 加上jquery代码就可以了 关于表单获取焦点,chr ...
- 让div支持placeholder属性/模拟输入框的placeholder属性
实现方式:css div:empty:before{ content: attr(placeholder); color:#bbb;}div:focus:before{ content:none; }
- IE9以下不支持placeholder属性
jquery.placeholder.min.js 这个js可以去这个网站搜索https://www.bootcdn.cn/jquery-placeholder/ 使用这个jquery.placeho ...
- i8浏览器不支持placeholder属性解决办法,以及解决后,文字不居中问题
这里想实现的效果是:设置和移除文本框默认值,如下图鼠标放到文本框中的时候,灰字消失. 1.可以用简单的方式,就是给input文本框加上onfocus属性,如下代码: <input id=&quo ...
随机推荐
- <a>标签的href和onclick属性
讨论 <a>标签中,href和onclick事件的顺序与冲突问题. 首先明确一点:链接的onclick 事件被先执行,其次是href属性下的动作(页面跳转,或 javascript 伪链接 ...
- (1)as_view() (2)在urls.py里面出现的pk是怎么回事 (3)RetrieveAPIView表示什么
下面的代码都是我从github上下载的源码中摘取的django: https://github.com/django/django 下载命令: git clone https://github.com ...
- Excel 数值转换为人民币大写金额字符串
把$B$27单元格中的数值转换为人民币大写金额字符串: 目标单元格填入以下公式: =IF($B$27=0,CONCATENATE(IF($B$27<=0,,TEXT(INT($B$27),&qu ...
- IIS中使用LocalDB遇到错误:error 50,Local Database Runtime error occurred.的解决办法
参见: [1] http://www.cnblogs.com/yjmyzz/archive/2009/10/26/1590033.html [2] http://blogs.msdn.com/b/sq ...
- new String(“a”)与String a="a";
String a=new String ("a"); String b=new String ("a"); //这是比较地址 System.out.printl ...
- Factstone Benchmark
[问题描述] Amtel已经宣布,到2010年,它将发行128位计算机芯片:到2020年,它将发行256位计算机:等等,Amtel坚持每持续十年将其字大小翻一番的战略.(Amtel于2000年发行了6 ...
- 一个继承TList的例子
类声明部分: TDMSTrains = class(TList) private FHashed: Boolean; FHashList: TFpHashList; FOwnsObjects: Boo ...
- mysql 循环插入日期递增
create procedure wk() begin declare i int; ; do insert into t (myday) values (date_sub(curdate(),int ...
- UzysAssetsPickerController中文化
self.labelSelectedMedia.text = NSLocalizedStringFromTable(@"Choose a media", @"UzysAs ...
- RGBA 与opacity
RGBA是一种表示颜色的方式,初次看到觉得很奇怪,与RGB的区别是什么?后面查了下,才发现RGBA的好处. RGBA各个字母的含义为: R:红色值,正整数 | 百分数: G:绿色值,正整数 | 百分数 ...