Arb*_*æde 131 html5 internet-explorer placeholder
我有一个小问题,placeholderIE 8-9不支持输入框的属性.
在我的项目(ASP Net)中提供此支持的最佳方法是什么.我正在使用jQuery.我需要使用其他一些外部工具吗?
是http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html好的解决办法?
sta*_*abs 89
您可以使用以下任何一种填充物:
这些脚本将placeholder在不支持它的浏览器中添加对属性的支持,并且它们不需要jQuery!
red*_*ert 88
你可以使用这个jQuery插件:https: //github.com/mathiasbynens/jquery-placeholder
但你的链接似乎也是一个很好的解决方案.
小智 24
在$ .Browser.msie是不是最新的JQuery了...你必须使用$.支持
如下:
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
238586 次 |
| 最近记录: |