Share with colleagues today on the input attribute placeholder in IE9 incompatible solutions, the younger brother is not very good, I hope to have a big brother talk about your reading comprehension
<script src="http://www.jq22.com/jquery/1.8.3/jquery.min.js"></script> <script> (function($){ $.fn.placeholder = function(options){ var opts = $.extend({}, $.fn.placeholder.defaults, options); var isIE = document.all ? true : false; return this.each(function(){ var _this = this, placeholderValue =_this.getAttribute("placeholder"); //缓存默认的placeholder值 if(isIE){ _this.setAttribute("value",placeholderValue); _this.onfocus = function(){ $.trim(_this.value) == placeholderValue ? _this.value = "" : ''; }; _this.onblur = function(){ $.trim(_this.value) == "" ? _this.value = placeholderValue : ''; }; } }); }; })(jQuery); $("input").placeholder(); </script>
After reading the analysis required under chiefs, or another day so I asked again to share with everyone.