我有一个动态输入框,根据数据添加需要增加其中的高度。我试图在JavaScript中使用10个字符后添加新行,但它不反映在输入标记中。输入标签的自动高度设置
我的代码是
for(var i=0; i < field.length; i++)
cityNameLength = cityNames.length;
tempLength = cityNameLength;
if(tempLength > 12)
{
tempLength = 0;
cityNames+='\r\n';
}
}
document.getElementById('val').value =cityNames ; // it is displaying everything in one line
和
<input type="text" id="val"/>
这是非常人性化的,他错过了这里没有在实际的代码或否则他会在编译时出错。 –