<script type="text/javascript">
(function ($) {
if (!("placeholder" in document.createElement("input"))) {
var originalVal = $.fn.val;
$.fn.val = function(value) {
if (arguments.length >= 1) {
return originalVal.call(this, value);
} else {
if ($(this).attr("value") == $(this).attr("placeholder")) {
$(this).attr("value", "");
}
}
return originalVal.call(this);
};
}
})(jQuery);
</script>
转载于:https://www.cnblogs.com/yiwantang/p/4517025.html