本文介绍了文本框自动扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过javascript使文本框自动扩展
how can i make textbox auto expandable through javascript
推荐答案
您可以将值的计数与行* cols进行比较。我真的不知道html中的col有多少个字母,但如果你测试过你可以做类似的事情:
You could compare the count of your value with the rows * cols. I dont really know how many letters there are in a col in html but if you tested that you could do something like:
var colCount = document.yourForm.yourTextArea.cols;
var rowCount = document.yourForm.yourTextArea.rows;
if((colCount * numberOfLettersInACol) * rowCount) <= document.yourForm.yourTextArea.value.length){
document.yourForm.yourTextArea.rows = rowCount + 1;
}
这篇关于文本框自动扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!