Skip to content

Instantly share code, notes, and snippets.

@higeorange
Created September 22, 2010 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save higeorange/592245 to your computer and use it in GitHub Desktop.
Save higeorange/592245 to your computer and use it in GitHub Desktop.
(function($) {
$.fn.autoResizeTextarea = function() {
return this.each(function() {
if(this.tagName.toLowerCase() != "textarea") return;
var dr = this.getAttribute("rows");
$(this).css("overflow", "hidden").keyup(function() {
var l = this.value.split("\n").length;
if(dr < l) {
this.setAttribute("rows", l);
} else {
this.setAttribute("rows", dr);
}
});
});
}
})(jQuery);
@higeorange
Copy link
Author

挙動カクカク気持ち悪い

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment