如何在IE8和9中支持占位符属性

如何在IE8和9中支持占位符属性,第1张

如何在IE8和9中支持占位属性

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


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/5621108.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存