创建具有自动调整大小的文本区域
textareaclientHeighttextarea
function FitToContent(id, maxHeight){
var text = id && id.style ? id : document.getElementById(id);
if ( !text )
return;
var adjustedHeight = text.clientHeight;
if ( !maxHeight || maxHeight > adjustedHeight )
{
adjustedHeight = Math.max(text.scrollHeight, adjustedHeight);
if ( maxHeight )
adjustedHeight = Math.min(maxHeight, adjustedHeight);
if ( adjustedHeight > text.clientHeight )
text.style.height = adjustedHeight + "px";
}}window.onload = function() {
document.getElementById("ta").onkeyup = function() {
FitToContent( this, 500 )
};}
斯蒂芬大帝
随时随地看视频慕课网APP