zoukankan      html  css  js  c++  java
  • placeholder 不支持ie8

    //判断是否存在placeholder属性

                        function placeholder(el){
    				function isPlaceHolder(){
    					var textarea = document.createElement("textarea");
    					return "placeholder" in textarea;
    				}	
    			
    			//在不支持placeHolder属性的情况下
    			if(isPlaceHolder() == false && !('placeholder' in document.createElement('textarea'))){
    				$('textarea[placeholder]').each(function(){
    					var that = $(this);
    					text = that.attr('placeholder');
    					
    					if(that.val()===""){
    						that.val(text);
    					}
    					
    					//获得光标焦点后,输入框的内容清空
    					that.focus(function(){
    						if(that.val() == text){
    							that.val("");
    						}
    					}).blur(function(){
    						//光标焦点离开输入框时,给输入框添加提示内容
    						if(that.val() === ""){
    							that.val(text);
    						}
    					})
    				})
    			}
    		}
  • 相关阅读:
    2020/8/8
    2020/8/7
    2020/8/6
    2020/8/5
    2020/8/4
    2020/8/3
    19,CSS 滤镜
    18 章 CSS 链接、光标、 DHTML 、缩放
    17 , CSS 区块、浮动、定位、溢出、滚动条
    16 , CSS 边框与边界
  • 原文地址:https://www.cnblogs.com/sidekick/p/9874179.html
Copyright © 2011-2022 走看看