讓IE也支持placeholder的方法

//IE也支持placeholder
			placeholderUp();
		function  placeholderUp(){
			var i = document.createElement('input'),
			    laceholdersupport = 'placeholder' in i;
				//只處理IE的狀況
				if(!placeholdersupport){
				    var inputObj = $(':text');
				    inputObj.each(function(){
					var that = $(this),
					    thatPlaceholder = that.attr("placeholder");
					    that.val(thatPlaceholder);
					    that.on('focus',function(){
						if(that.val() == thatPlaceholder){
							that.val('');
							}
						})
					    that.on('blur',function(){
						if(!that.val()){
							that.val(thatPlaceholder);
							}
						})
					});
					
				}
			}

注:依賴Jquerythis

相關文章
相關標籤/搜索