이 기사에서는 적응력 높이 형태 텍스트 상자를 구현하는 JS 방법에 대해 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
코드를 다음과 같이 복사하십시오.
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<title> js는 적응력 높이 양식 텍스트 상자 </title>를 구현합니다
<스타일 유형 = "텍스트/CSS">
#shadow, #text {font : 12px/16px arial; 너비 : 200px; 오버플로 : 숨겨진; 높이 : 16px; }
#shadow {위치 : 절대; 테두리 width : 0px; 패딩 : 0px; 가시성 : 숨겨진; }
#text {resize : 없음; }
</스타일>
<script type = "text/javaScript">
Window.onload = function () {
var text = document.getElementById ( "text"); // 사용자가 본 텍스트 상자
var shadow = document.getElementById ( "Shadow"); // 숨겨진 텍스트 상자
text.oninput = // nonie
text.onpropertychange = // 즉
onchange;
onchange () {
Shadow.Value = Text.Value;
Setheight ();
settimeout (Setheight, 0); // IE 6/7/8의 지연에 대해서는 캐릭터 항목과 종료가 있습니다.
함수 setheight () {text.style.height = shadow.scrollheight + "px"; }
}
};
</스크립트>
</head>
<body>
<TextArea id = "text"> </textArea>
<TextArea id = "섀도우"> </textRea>
</body>
</html>
이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.