最近的文章列表

解决IE6、IE7、IE8、IE9不支持HTML5 placeholder属性值的方案

placeholder 是HTML5的新属性,在做input 的预设值还挺方便的,但无奈IE8以下不支持,因此需要额外做fix。在实际使用中,却遇到了很多问题:

例如在官网查到的plugin:http://plugins.jquery.com/project/input-placeholder,就不支持type="password"的结果。因为仅改变value,对应password的显示方式

以下是我找到支持度最好地plugin:

DEMO: http://mathiasbynens.be/demo/placeholder

plugin: https://github.com/mathiasbynens/Placeholder-jQuery-Plugin

2015/10/21 Comments:
解决ie7 ie8不支持trim的属性的方法

在ie 7 8浏览器中,如果使用trim()属性去除空格的话,则会导致报错。

因此解决这个问题有如下方案:

JS去除空格的方法目前共有12种:

实现1
String.prototype.trim = function() { return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }
实现2
String.prototype.trim = function() { return this.replace(/^\s+/, '').replace(/\s+$/, ''); }
实现3
String.prototype.trim = function

2014/5/24 Comments: