ie下textarea的placeholder屬性不顯示的簡單解決方案

第一種:原因是<textarea placeholder="最長爲128個字" >(這裏有空格)</textarea>,去掉空格就行

第二種:頁面引入jquery.placeholder.js,和jquery-1.8.0.min.js(這個放在前面)

鏈接: https://pan.baidu.com/s/1ly83X3ICeaAVHPTSbuOjIw 提取碼: xf5p

第三種:個人認爲最簡單方便,直接在頁面上加上一下代碼就能解決

    $(function () {
    	  if(!placeholderSupport()){   // 判斷瀏覽器是否支持 placeholder
    	      $('[placeholder]').focus(function() {
    	          var input = $(this);
    	          if (input.val() == input.attr('placeholder')) {
    	              input.val('');
    	              input.removeClass('placeholder');
    	          }
    	      }).blur(function() {
    	          var input = $(this);
    	          if (input.val() == '' || input.val() == input.attr('placeholder')  ) {
    	              input.addClass('placeholder');
    	              if(input[0].tagName=="TEXTAREA")
    	                input.text(input.attr('placeholder'));
    	              else
    	                input.val(input.attr('placeholder'));
    	          }
    	      }).blur();
    	  };
    	  function placeholderSupport() {
  		    return 'placeholder' in document.createElement('input');
  		  }
        $(".accordions dt").on("click",function(){
            if(!$(this).parent().hasClass("expand")){
                $(this).siblings("dt").removeClass("active")
                $(this).toggleClass("active")
                var target = $(this).next("dd");
                target.siblings("dd").slideUp();
                target.slideToggle();
            }
        });
    })

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章