我有一个小问题,IE 8-9不支持输入框的placeholder
属性。
在我的项目(ASP.NET)中提供这种支持的最好方法是什么?我正在使用jQuery。我需要使用一些其他的外部工具吗?
http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html是一个好的解决方案吗?
发布于 2013-02-22 17:32:33
您可以使用这个jQuery插件:https://github.com/mathiasbynens/jquery-placeholder
但是你的链接似乎也是一个很好的解决方案。
发布于 2013-02-22 17:51:57
您可以使用以下任意一种多边形填充:
这些脚本将在不支持placeholder
属性的浏览器中添加对它的支持,并且它们不需要jQuery!
发布于 2014-02-08 04:50:25
$.Browser.msie不再是最新的JQuery ...您必须使用$.support
如下所示:
<script>
(function ($) {
$.support.placeholder = ('placeholder' in document.createElement('input'));
})(jQuery);
//fix for IE7 and IE8
$(function () {
if (!$.support.placeholder) {
$("[placeholder]").focus(function () {
if ($(this).val() == $(this).attr("placeholder")) $(this).val("");
}).blur(function () {
if ($(this).val() == "") $(this).val($(this).attr("placeholder"));
}).blur();
$("[placeholder]").parents("form").submit(function () {
$(this).find('[placeholder]').each(function() {
if ($(this).val() == $(this).attr("placeholder")) {
$(this).val("");
}
});
});
}
});
</script>
https://stackoverflow.com/questions/15020826
复制相似问题