标签:nts ie兼容 creat class his default length var style
直接上代码:
$(document).ready(function () { var doc = document, textareas = doc.getElementsByTagName(‘textarea‘), supportPlaceholder = ‘placeholder‘ in doc.createElement(‘textarea‘), placeholder = function (textarea) { var text = textarea.getAttribute(‘placeholder‘), defaultValue = textarea.defaultValue; if (defaultValue == ‘‘) { textarea.value = text } textarea.onfocus = function () { if (textarea.value === text) { this.value = ‘‘ } }; textarea.onblur = function () { if (textarea.value === ‘‘) { this.value = text } } }; if (!supportPlaceholder) { for (var i = 0, len = textareas.length; i < len; i++) { var textarea = textareas[i], text = textarea.getAttribute(‘placeholder‘); if ( text) { placeholder(textarea); } } } });
textarea可以换成input
标签:nts ie兼容 creat class his default length var style
原文地址:http://www.cnblogs.com/hectorE/p/6088393.html