Created
September 22, 2010 18:39
-
-
Save higeorange/592245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
挙動カクカク気持ち悪い