댓글 textarea 자동 높이조절 입니다 정보
댓글 textarea 자동 높이조절 입니다본문
<script type="text/javascript">
function autoTextarea(obj,limit) {
obj.style.height = "1px";
if (limit >= obj.scrollHeight) obj.style.height = (20+obj.scrollHeight)+"px";
else obj.style.height = (20+limit)+"px";
}
</script>
요기까지 상단에 넣으시고
textarea 부분에서
<?php if ($comment_min || $comment_max) { ?><strong id="char_cnt"><span id="char_count"></span>글자</strong><?php } ?>
<textarea onkeyup="autoTextarea(this,100);" class=nbbs id="wr_content" name="wr_content" rows="5" maxlength="10000" required title="내용"
<?php if ($comment_min || $comment_max) { ?>onkeyup="check_byte('wr_content', 'char_count');"<?php } ?> style='width:100%; word-break:break-all;' class=tx><?php echo $c_wr_content; ?></textarea>
<?php if ($comment_min || $comment_max) { ?><script> check_byte('wr_content', 'char_count'); </script><?php } ?>
<script>
$(document).on( "keyup change", "textarea#wr_content[maxlength]", function(){
var str = $(this).val()
var mx = parseInt($(this).attr("maxlength"))
if (str.length > mx) {
$(this).val(str.substr(0, mx));
return false;
}
});
</script>
요걸 넣으시면 됩니다.
2