textarea自动高度,怎么每输入一次就加高呢?把头部<!DOCTYPE html>换成<html>就不会,怎么回事 30
<!DOCTYPEhtml><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Conten...
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body,div,input,select,textarea{margin:2px 3px 2px 3px;font-size:12.5pt;line-height:25px;}
body{color: #000000; background-color: #eeffee;}
form{margin: 0px;display: inline;}
.aa{border-width:2px;border-color:#5C3C00;border-style:solid;text-align:center;}
.aa textarea{
width: 99%;
height: 120px;
padding: 2px 3px;
margin:5px 2px 5px 2px;
border-radius:5px;
overflow: auto;
}
</style>
<script language= "javascript">
function OutHg(iTs,Fot){
iTs.style.overflow= "hidden";
var G=iTs.scrollHeight
if (G<120){G=120} //最低120px
iTs.style.posHeight=G;
}
</script>
<title>测试</title></head>
<%
Response.Write "<div class=""aa"">"& chr(13) &""
Response.Write "<textarea onclick='OutHg(this)' oninput='OutHg(this)' id='AAA' >手动a抒发"& chr(13) &""& chr(13) &""& chr(13) &""& chr(13) &""& chr(13) &""& chr(13) &"fdddssd感情a</textarea>"
Response.Write "</div>"
%>
</body></html> 展开
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body,div,input,select,textarea{margin:2px 3px 2px 3px;font-size:12.5pt;line-height:25px;}
body{color: #000000; background-color: #eeffee;}
form{margin: 0px;display: inline;}
.aa{border-width:2px;border-color:#5C3C00;border-style:solid;text-align:center;}
.aa textarea{
width: 99%;
height: 120px;
padding: 2px 3px;
margin:5px 2px 5px 2px;
border-radius:5px;
overflow: auto;
}
</style>
<script language= "javascript">
function OutHg(iTs,Fot){
iTs.style.overflow= "hidden";
var G=iTs.scrollHeight
if (G<120){G=120} //最低120px
iTs.style.posHeight=G;
}
</script>
<title>测试</title></head>
<%
Response.Write "<div class=""aa"">"& chr(13) &""
Response.Write "<textarea onclick='OutHg(this)' oninput='OutHg(this)' id='AAA' >手动a抒发"& chr(13) &""& chr(13) &""& chr(13) &""& chr(13) &""& chr(13) &""& chr(13) &"fdddssd感情a</textarea>"
Response.Write "</div>"
%>
</body></html> 展开
1个回答
2019-07-01
展开全部
function setTextareaHei () {
$('textarea').each(function () {
this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
}).on('input', function () {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
})
}
搬家就选上海公兴搬家有限公司,给你完美的搬家体验!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询