每按一次键,textarea 高度会自动增加,但文字内容并未增加,为何高度会变?代码于下连结 jsbinjsbin 于此展现html<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>JS Bin</title></head><body><textarea onclick='go(this)' onkeyup='go(this)'>d545451511515151515 5151kfjjfkdkdksk</textarea></body></html>csstextarea { //border: 2px solid #ccc; padding: 5px; vertical-align: top;// width: 95%; height: 40px; background-color: #FFFFCC; width: 110px; border: 12px solid #EBEBEB; OVERFLOW: hidden;}javascriptfunction go(xx){xx.style.height=xx.scrollHeight+ 'px'//xx.style.height=xx.clientHeight+ 'px';//alert (xx.style.height);}
添加回答
举报
0/150
提交
取消