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
在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