解决IE6、IE7、IE8、IE9不支持HTML5 placeholder属性值的方案
分类:Javascript| 发布:佚名| 查看:1238 | 发表时间:2015/10/21
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
引入:
02 | <script src= "/libs/html5/modernizr-custom.js" ></script> |
03 | <script src= "/libs/html5/json2.js" ></script> |
04 | <script src= "/libs/html5/storage.js" ></script> |
05 | <script src= "/libs/html5/jquery.placeholder.min.js" ></script> |
06 | <script type= "text/javascript" > |
08 | $( 'input, textarea' ).placeholder(); |