textarea自动增高并隐藏滚动条
<script type="text/javascript">
function autoHeight(self){
$('#testbox').html($(self).val());
var height = $('#testbox').outerHeight();
if(height<20){
return;
}
$(self).scroll(function(){
$(self).scrollTop(0);
});
$(self).outerHeight(height);
}
</script>
<textarea class="autoheight" id="tValue" style="overflow-y:hidden; height:20px;" onpropertychange="autoHeight(this)" oninput="autoHeight(this)" onkeyup="autoHeight(this)" onkeydown="autoHeight(this)" ></textarea>
<pre class="autoheight" style="" id="testbox"> </pre>
<style type="text/css">
.autoheight{ padding: 5px; border:1px solid #666; line-height: 20px; font-size: 14px; }
</style>