亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

MMTTMM 2019-10-17 14:08:50
我有一個小問題,placeholderIE 8-9不支持輸入框的屬性。在我的項目(ASP Net)中獲得這種支持的最佳方法是什么。我正在使用jQuery。我需要使用其他一些外部工具嗎?是http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html好的解決辦法?
查看完整描述

3 回答

?
絕地無雙

TA貢獻1946條經驗 獲得超4個贊

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


查看完整回答
反對 回復 2019-10-17
  • 3 回答
  • 0 關注
  • 581 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號