0
我有这个textarea,我正在做一个自动调整大小,并为此我使用scrollHeight属性。即使页面刚刚加载且字段为空,FF看起来与Chrome非常不同。我已经看过了一些建议(如stackoverflowlink),但我不知道如何让他们看起来是一样的FF和铬中的文本区域显示相同的大小
这是需要调整的照顾代码:
$('#idTextArea').each(function() {
this.setAttribute('style', 'overflow-y:hidden;width:600px;');
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
console.log("this.scrollHeight",this.scrollHeight);
}).on('input', function() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
,这是字段:
<textarea id="idTextArea"
name="textName"
maxlength="200"
style="width: 600px;"><%=controller.getText("textName") == null? "":controller.getText("textName")%></textarea>
当我的页面加载时,console.log在Chorme上打印26,在FF上打印49。 所以我的问题是:如何让他们看起来一样?
''px; overflow-y:hidden; width:600px;'' - px应该是什么样的风格? –
以及颜色编码显示错误 – epascarello
@JaromandaX,对不起,这只是一个错字。我删除了它 –