javascript 适用于 ie7、ie8 和 ie9 的最佳占位符 polyfil 脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15436125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The best placeholder polyfil script for ie7, ie8 and ie9
提问by Jujhar Singh
Which placeholder polyfill script do you recommend that I use to provide placeholder support in ie7, 8 & 9.
你推荐我使用哪个占位符 polyfill 脚本来在 ie7、8 和 9 中提供占位符支持。
I've seen the following listfrom the modernizer team and was wondering if anybody here had some mileage with them or any others not on the list and what they think is the best
我已经看到了现代化团队的以下列表,想知道这里是否有人与他们或其他不在列表中的人有过一些合作,以及他们认为什么是最好的
My criteria for evaluation would be:
我的评价标准是:
- File Size
- Ability to work without modernizer/yepnope
- Speed (no crazy looping)
- Stability, how much as it been used in the wild?
- Detect native placeholder ability and not bother running
- 文件大小
- 无需现代化者即可工作的能力/是的
- 速度(没有疯狂的循环)
- 稳定性,它在野外使用了多少?
- 检测本机占位符能力而不打扰运行
I remember a day when I used to write a line or so in the onclick event of an input for placeholder support - lol, but to be honest I can't bothered to support these horrible browsers (watch this funny). At least IE10 is finally moving in the right direction.
我记得有一天我曾经在占位符支持的输入的 onclick 事件中写一行左右 - 大声笑,但老实说我懒得支持这些可怕的浏览器(看这很有趣)。至少 IE10 终于朝着正确的方向发展了。
Thank you...
谢谢...
回答by Elijah Manor
I recommend you use the jQuery Placeholderpolyfill by Mathias Bynens.
我建议你使用jQuery的占位符的填充工具马蒂亚斯Bynens。
- It supports IE6+
- It is 2k minified
- It does its own feature detection (Modernizr isn't needed)
- The code is straightforward. The jQuery selection will vary depending on your selector
- It is the one polyfill recommended by HTML5Pleaseand is listed on the Modernizr Wikiyou mentioned
- It doesn't execute the code if it isn't needed
- 它支持IE6+
- 缩小了 2k
- 它进行自己的特征检测(不需要 Modernizr)
- 代码很简单。jQuery 选择将因您的选择器而异
- 它是HTML5Please推荐的一种polyfill,并列在您提到的Modernizr Wiki 上
- 如果不需要,它不会执行代码