1、可直接在 菜鸟教程网站测试页面中测试
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<textarea style="width: 200px;padding:0px;"
id="symptomTxt"
oninput="autoTextAreaHeight(this)"
>
</textarea>
</body>
<script type="text/javascript">
//文本域自适应
function autoTextAreaHeight(o) {
o.style.height = o.scrollTop + o.scrollHeight + "px";
}
$(function () {
var ele = document.getElementById("symptomTxt");
autoTextAreaHeight(ele);
})
</script>
</html>