当我的光标位于该区域的底部并且按回车键以创建新行时,我的文本区域没有扩展。我可以在我的应用程序中扩展其他文本区域,因此我认为周围有一些元素阻止我键入时扩展/调整大小?有什么想法吗?
这是我的HTML和渲染的HTML
<div class="form-group">
@Html.LabelFor(model => model.OverviewSummary, new { @class = "control-label" })
<form id="OverviewSummarySubmit">
@Html.TextAreaFor(model => model.OverviewSummary, new { @class = "form-control input-lg", @style = "min-height: 64px; max-height: 460px; max-width: 500px; overflow: hidden", data_id = Model.YogaSpaceId, data_url = Url.Action("UpdateSummary", "ManageSpaces") })
@Html.ValidationMessageFor(model => model.OverviewSummary, "", new { @class = "text-danger", @style = "font-weight: bold;" })
</form>
</div>
<textarea name="OverviewSummary" class="form-control input-lg valid" id="OverviewSummary" aria-invalid="false" aria-describedby="OverviewSummary-error" style="height: 90px; overflow: hidden; min-height: 64px; max-height: 460px; max-width: 500px;" rows="2" cols="20" data-val="true" data-id="3" data-val-maxlength-max="1500" data-val-maxlength="Maximum Length 1500 Characters." data-url="/ManageSpaces/3/UpdateSummary">This is at Alamo Square Park near Hayes Valley. The cat jumped over the roof to get the mouse.
I like trees!
When I jump its high!
</textarea>
这是带有文本的文本区域
这是我按回车几次后的文本区域(不重新定尺寸!)
最佳答案
哎呀!我注意到我在其他可以调整文本区域大小的页面上使用了此功能
$('textarea').on('input', function () {
$(this).outerHeight(20).outerHeight(this.scrollHeight);
});
$('textarea').trigger('input');
关于html - Textarea不会随着回车而调整大小或扩展,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36052287/